* @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
$file = CValue::read($_FILES, "import");
$smarty = new CSmartyDP();
if (!$file) {
    $smarty->display("inc_import_mode_traitement_sejour.tpl");
    CApp::rip();
}
$group_id = CGroups::loadCurrent()->_id;
$csv = new CCSVFile($file["tmp_name"], CCSVFile::PROFILE_EXCEL);
$csv->readLine();
while ($line = $csv->readLine()) {
    list($code, $libelle, $type_sejour, $type_pec, $actif) = $line;
    $charge_price = new CChargePriceIndicator();
    $charge_price->code = $code;
    $charge_price->libelle = $libelle;
    $charge_price->type = $type_sejour;
    $charge_price->type_pec = $type_pec;
    $charge_price->group_id = $group_id;
    $charge_price->loadMatchingObject();
    $charge_price->actif = $actif;
    if ($msg = $charge_price->store()) {
        CAppUI::displayAjaxMsg($msg, UI_MSG_WARNING);
        continue;
    }
    CAppUI::displayAjaxMsg("importation terminée", UI_MSG_OK);
}
$smarty->display("inc_import_mode_traitement_sejour.tpl");
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
$mode_class = CValue::get("mode_class");
$file = CValue::read($_FILES, "import");
$smarty = new CSmartyDP();
$smarty->assign("mode_class", $mode_class);
if (!$file) {
    $smarty->display("inc_import_mode_entree_sortie_sejour.tpl");
    CApp::rip();
}
$group_id = CGroups::loadCurrent()->_id;
$csv = new CCSVFile($file["tmp_name"], CCSVFile::PROFILE_EXCEL);
$csv->readLine();
while ($line = $csv->readLine()) {
    list($code, $libelle, $mode, $actif) = $line;
    /** @var CModeEntreeSejour|CModeSortieSejour $mode_entree_sortie */
    $mode_entree_sortie = new $mode_class();
    $mode_entree_sortie->code = $code;
    $mode_entree_sortie->libelle = $libelle;
    $mode_entree_sortie->mode = $mode;
    $mode_entree_sortie->group_id = $group_id;
    $mode_entree_sortie->loadMatchingObject();
    $mode_entree_sortie->actif = $actif;
    if ($msg = $mode_entree_sortie->store()) {
        CAppUI::displayAjaxMsg($msg, UI_MSG_WARNING);
        continue;
    }
    CAppUI::displayAjaxMsg("importation terminée");
}
$smarty->display("inc_import_mode_entree_sortie_sejour.tpl");
    $time = $results_query->getTotalTime();
    $nbresult = $results_query->getTotalHits();
    foreach ($results as $result) {
        $var = $result->getHit();
        $var["_source"]["body"] = mb_convert_encoding($var["_source"]["body"], "WINDOWS-1252", "UTF-8");
        $array_results[] = $var;
        $author_ids[] = $var["_source"]["user_id"];
        $highlights = $result->getHighlights();
        if (count($highlights) != 0) {
            $array_highlights[] = mb_convert_encoding(implode(" [...] ", $highlights['body']), "WINDOWS-1252", "UTF-8");
        } else {
            $array_highlights[] = "";
        }
    }
    // traitement des auteurs
    foreach ($author_ids as $author) {
        $authors[$author] = CMbObject::loadFromGuid("CMediusers-{$author}");
        $authors[$author]->loadRefFunction();
    }
} catch (Exception $e) {
    CAppUI::displayAjaxMsg("Problème à la récupération des données", UI_MSG_ERROR);
}
$smarty = new CSmartyDP();
$smarty->assign("authors", $authors);
$smarty->assign("results", $array_results);
$smarty->assign("highlights", $array_highlights);
$smarty->assign("objects_refs", null);
$smarty->assign("time", $time);
$smarty->assign("nbresult", $nbresult);
$smarty->assign("date_log_details", $date);
$smarty->display("inc_results_log_details.tpl");
Esempio n. 4
0
<?php

/**
 * $Id$
 *  
 * @category Search
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 * @link     http://www.mediboard.org */
CCanDo::checkAdmin();
$names_types = CValue::get("types");
$error = "";
try {
    $client_index = new CSearch();
    //create a client
    $client_index->createClient();
    $index = $client_index->getIndex(CAppUI::conf("db std dbname"))->exists();
    $client_index->updateIndex($index);
    CAppUI::displayAjaxMsg("L'index " . CAppUI::conf("db std dbname") . " s'est correctement mis à jour", UI_MSG_OK);
} catch (Exception $e) {
    CAppUI::displayAjaxMsg("L'index " . CAppUI::conf("db std dbname") . " n'a pas été mis à jour", UI_MSG_ERROR);
    $error = "update";
}
$smarty = new CSmartyDP();
$smarty->assign("error", $error);
$smarty->display("inc_configure_es.tpl");
Esempio n. 5
0
 *
 * @param string $lock_file The file which lock traitement
 *
 * @return void
 */
function rmLock($lock_file)
{
    @unlink($lock_file);
}
register_shutdown_function("rmLock", $lock_file);
// LOCK //
touch($lock_file);
set_time_limit(600);
set_min_memory_limit("1024M");
//TRAITEMENT
$name_repository = CValue::get("name_repository");
$dir_repository = CValue::get("dir_repository");
$name_snapshot = CValue::get("name_snapshot");
try {
    $snapshot = new CSearchSnapshot();
    //create a client
    $snapshot->createClient();
    $snapshot->loadIndex();
    $snapshot->createSnapshot();
    //$snapshot->deleteIndexAndRestore($name_repository, $name_snapshot, true, true);
    $snapshot->snapshot($name_repository, CAppUI::getTmpPath($dir_repository), $name_snapshot);
    CAppUI::displayAjaxMsg("La création du snapshot de l'index s'est bien déroulée", UI_MSG_OK);
} catch (Exception $e) {
    mbLog($e->getMessage());
    CAppUI::displayAjaxMsg("La création du snapshot de l'index a recontré un problème", UI_MSG_WARNING);
}
Esempio n. 6
0
$client_index = new CSearchLog();
$client_index->createClient();
$words = $client_index->constructWordsWithDate($_date, $_min_date, $_max_date);
$words = $client_index->constructWordsWithUser($words, CMediusers::get()->_id);
// Recherche fulltext
$time = 0;
$nbresult = 0;
$array_results = array();
try {
    $results_query = $client_index->searchQueryString('AND', $words, $start, 20, null, null);
    $results = $results_query->getResults();
    $time = $results_query->getTotalTime();
    $nbresult = $results_query->getTotalHits();
    // traitement des résultats
    foreach ($results as $result) {
        $var = $result->getHit();
        $var["_source"]["body"] = mb_convert_encoding($var["_source"]["body"], "WINDOWS-1252", "UTF-8");
        $author_ids[] = $var["_source"]["user_id"];
        $array_results[] = $var;
    }
} catch (Exception $e) {
    CAppUI::displayAjaxMsg("La requête est mal formée", UI_MSG_ERROR);
    mbLog($e->getMessage());
}
$smarty = new CSmartyDP();
$smarty->assign("start", $start);
$smarty->assign("results", $array_results);
$smarty->assign("time", $time);
$smarty->assign("nbresult", $nbresult);
$smarty->assign("show_score", false);
$smarty->display("inc_search_result_thesaurus.tpl");
                default:
                    return;
            }
            $response = CSocketBasedServer::send("localhost", $port, $server_class::sampleMessage());
            echo "<pre class='er7'>{$response}</pre>";
            return;
        } catch (Exception $e) {
            CAppUI::displayAjaxMsg($e->getMessage(), UI_MSG_ERROR);
        }
        break;
    case "stats":
        try {
            mbTrace(json_decode(CSocketBasedServer::send("localhost", $port, "__" . strtoupper($action) . "__\n"), true));
        } catch (Exception $e) {
            CAppUI::stepAjax($e->getMessage(), UI_MSG_ERROR);
        }
        return;
    default:
        CAppUI::displayAjaxMsg("Unknown command '{$action}'", UI_MSG_ERROR);
}
$processes = CSocketBasedServer::getPsStatus();
$process_id = CValue::get("process_id");
if (!array_key_exists($process_id, $processes)) {
    return;
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("process_id", $process_id);
$smarty->assign("uid", $uid);
$smarty->assign("_process", $processes[$process_id]);
$smarty->display("inc_server_socket.tpl");
Esempio n. 8
0
    $function_id = $user->loadRefFunction()->_id;
    $whereFavoris["function_id"] = " = '{$function_id}'";
    $tab_favoris_function_sans_cibles = $favoris_sans_cibles->loadList($whereFavorisSansCibles);
    unset($whereFavorisSansCibles["function_id"]);
    $group_id = $user->loadRefFunction()->group_id;
    $whereFavorisSansCibles["group_id"] = " = '{$group_id}'";
    $tab_favoris_group_sans_cibles = $favoris->loadList($whereFavorisSansCibles);
    $tab_favoris += $tab_favoris_user_sans_cibles + $tab_favoris_function_sans_cibles + $tab_favoris_group_sans_cibles;
}
// On effectue la recherche automatique
if (isset($tab_favoris)) {
    try {
        $search = new CSearch();
        $results = $search->searchAuto($tab_favoris, $_ref_object);
    } catch (Exception $e) {
        CAppUI::displayAjaxMsg("search-not-connected", UI_MSG_ERROR);
        mbLog($e->getMessage());
    }
}
// Récupération des rss items pour le marquage pmsi (preuves de recherche PMSI)
$rss_items = array();
$items = array();
if ($contexte == "pmsi" && CModule::getActive("atih")) {
    $rss = new CRSS();
    $rss->sejour_id = $sejour_id;
    $rss->loadMatchingObject();
    $rss_items = $rss->loadRefsSearchItems();
    foreach ($rss_items as $_items) {
        $items[] = $_items->search_class . "-" . $_items->search_id;
    }
}
 * @package Mediboard
 * @subpackage eai
 * @version $Revision$
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 */
$process_id = CValue::get("process_id");
$uid = CValue::get("uid");
$tmp_dir = CSocketBasedServer::getTmpDir();
$pid_files = glob("{$tmp_dir}/pid.*");
foreach ($pid_files as $_file) {
    $_pid = substr($_file, strrpos($_file, ".") + 1);
    if ($process_id != $_pid) {
        continue;
    }
    if (@unlink($_file) === true) {
        CAppUI::displayAjaxMsg("Le fichier 'pid.{$process_id}' a été supprimé");
        return;
    }
}
CAppUI::displayAjaxMsg("Le fichier 'pid.{$process_id}' n'a pas pu être supprimé", UI_MSG_ERROR);
$processes = CSocketBasedServer::getPsStatus();
if (!array_key_exists($process_id, $processes)) {
    return;
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("process_id", $process_id);
$smarty->assign("uid", $uid);
$smarty->assign("_process", $processes[$process_id]);
$smarty->display("inc_server_socket.tpl");
Esempio n. 10
0
// LOCK //
touch($lock_file);
set_time_limit(600);
set_min_memory_limit("1024M");
//TRAITEMENT
try {
    $client_index = new CSearch();
    //create a client
    $client_index->createClient();
    $client_index->loadIndex();
    // Passage à l'indexation en tps réel pour améliorer la performance du bulk indexing
    $client_index->_index->setSettings(array("index" => array("refresh_interval" => "-1")));
    // récupère données de la table buffer avec le pas fournit en configuration
    $data = $client_index->getDataTemporaryTable(CAppUI::conf("search interval_indexing"), null);
    // on bulk index les data
    $client_index->bulkIndexing($data);
    CAppUI::displayAjaxMsg("L'indexation s'est correctement déroulée ", UI_MSG_OK);
    $error = "";
    // on remet le paramètre à défaut et on optimise l'index
    $client_index->_index->setSettings(array("index" => array("refresh_interval" => "1s")));
    $client_index->_index->optimize(array("max_num_segments" => "5"));
} catch (Exception $e) {
    mbLog($e->getMessage());
    CAppUI::displayAjaxMsg("L'indexation a recontré un problème", UI_MSG_WARNING);
    $error = "index";
}
// UNLOCK //
unlink($lock_file);
$smarty = new CSmartyDP();
$smarty->assign("error", $error);
$smarty->display("inc_configure_es.tpl");
Esempio n. 11
0
    CAppUI::displayAjaxMsg("Le serveur de recherche n'est pas connecté", UI_MSG_WARNING);
}
try {
    // récupération des données pour les journaux utilisateurs
    $client_log = new CSearchLog();
    $client_log->createClient();
    $infos_log = $client_log->loadCartoInfos();
} catch (Exception $e) {
    $infos_log = array();
    CAppUI::displayAjaxMsg("Le serveur de recherche de journaux n'est pas connecté", UI_MSG_WARNING);
}
try {
    // récupération des données pour les journaux utilisateurs
    $wrapper = new CSearchFileWrapper(null, null);
    $infos_tika = $wrapper->loadTikaInfos();
} catch (Exception $e) {
    mbLog($e);
    $infos_tika = "";
    CAppUI::displayAjaxMsg("Le serveur d'extraction de fichiers n'est pas connecté", UI_MSG_WARNING);
}
$ds = CSQLDataSource::get("std");
$query = "SELECT MIN(`date`) AS oldest_datetime FROM `search_indexing`";
$result = $ds->exec($query);
$oldest_datetime = $ds->fetchObject($result)->oldest_datetime;
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("infos_index", $infos_index);
$smarty->assign("infos_log", $infos_log);
$smarty->assign("infos_tika", $infos_tika);
$smarty->assign("oldest_datetime", $oldest_datetime);
$smarty->display("vw_cartographie_mapping.tpl");
Esempio n. 12
0
        foreach ($queries as $query) {
            $ds->exec($query);
        }
    }
    CAppUI::displayAjaxMsg("l'opération en base s'est déroulée avec succès ", UI_MSG_OK);
}
// Création du mapping pour l'index principal
try {
    if ($mapping) {
        $client_index = new CSearch();
        //create a client
        $client_index->createClient();
        $index = $client_index->getIndex(CAppUI::conf("db std dbname"))->exists();
        $client_index->firstIndexingMapping($names_types, $index);
        CAppUI::displayAjaxMsg("L'index " . CAppUI::conf("db std dbname") . " s'est correctement créé", UI_MSG_OK);
    }
} catch (Exception $e) {
    mbLog($e);
    CAppUI::displayAjaxMsg("L'index " . CAppUI::conf("db std dbname") . " existe déjà", UI_MSG_ERROR);
    $error = "mapping";
}
if ($log) {
    $client_index = new CSearchLog();
    //create a client
    $client_index->createClient();
    $index = $client_index->getIndex(CAppUI::conf("db std dbname") . "_log")->exists();
    $client_index->createLogMapping($index);
}
$smarty = new CSmartyDP();
$smarty->assign("error", $error);
$smarty->display("inc_configure_es.tpl");
Esempio n. 13
0
/**
 * $Id$
 *  
 * @category ${Module}
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  OXOL, see http://www.mediboard.org/public/OXOL
 * @link     http://www.mediboard.org */
CCanDo::checkAdmin();
$path = CAppUI::getTmpPath("pmsi");
$path .= "/cim10/LIBCIM10.TXT";
$result = array();
if (file_exists($path)) {
    if (!($fp = fopen("{$path}", "r+"))) {
        CAppUI::displayAjaxMsg("Echec de l'ouverture du fichier LIBCIM10.txt", UI_MSG_WARNING);
    } else {
        while (!feof($fp)) {
            // On récupère une ligne
            $ligne = fgets($fp);
            if ($ligne) {
                $ligne = utf8_encode($ligne);
                $_ligne = explode('|', $ligne);
                $_ligne = array_map("trim", $_ligne);
                $result[] = implode(";", $_ligne) . "\n";
            }
        }
        fclose($fp);
        // On ferme le fichier
    }
    $path = CAppUI::getTmpPath("pmsi");
Esempio n. 14
0
$lineCount = 0;
foreach ($files as $_file) {
    $name = basename($_file);
    $name = substr($name, strpos($name, "_") + 1);
    $table = substr($name, 0, strrpos($name, "."));
    $table = strtolower($table);
    if (!$ds) {
        CAppUI::stepAjax("Import impossible - Source non présente", UI_MSG_ERROR);
        continue;
    }
    $ds->query("CREATE TABLE IF NOT EXISTS `{$table}` (\r\n                `table_id` INT (11) UNSIGNED NOT NULL auto_increment PRIMARY KEY,\r\n                `code` VARCHAR (255) NOT NULL,\r\n                `oid` VARCHAR (255) NOT NULL,\r\n                `libelle` VARCHAR (255) NOT NULL,\r\n                INDEX (`table_id`)\r\n              )/*! ENGINE=MyISAM */;");
    $ds->query("DELETE FROM `{$table}`");
    $csv = new CCSVFile($_file);
    $csv->jumpLine(3);
    while ($line = $csv->readLine()) {
        list($oid, $code, $libelle) = $line;
        if (strpos($code, "/") === false || $oid === "1.2.250.1.213.1.1.4.6") {
            continue;
        }
        $query = "INSERT INTO `{$table}`(\r\n        `code`, `oid`, `libelle`)\r\n        VALUES (?1, ?2, ?3);";
        $query = $ds->prepare($query, $code, $oid, $libelle);
        $result = $ds->query($query);
        if (!$result) {
            $msg = $ds->error();
            CAppUI::displayAjaxMsg("Erreur de requête SQL: {$msg}", UI_MSG_ERROR);
            CApp::rip();
        }
        $lineCount++;
    }
}
CAppUI::stepAjax("Import effectué avec succès de {$lineCount} lignes", UI_MSG_OK);
Esempio n. 15
0
<?php

/**
 * $Id$
 *  
 * @category EAI
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
CCanDo::checkAdmin();
$exchange_guid = CValue::get("exchange_guid");
if (!$exchange_guid) {
    CAppUI::displayAjaxMsg("Pas d'objet passé en paramètre");
    CApp::rip();
}
$exchange = CMbObject::loadFromGuid($exchange_guid);
$exchange->loadRefsNotes();
if (!$exchange || $exchange && !$exchange->_id) {
    CAppUI::displayAjaxMsg("Aucun échange trouvé");
    CApp::rip();
}
$smarty = new CSmartyDP();
$smarty->assign("exchange", $exchange);
$smarty->display("inc_edit_exchange.tpl");
 /**
  * Get the exchange source
  *
  * @param string $name         Nom
  * @param string $type         Type de la source (FTP, SOAP, ...)
  * @param bool   $override     Charger les autres sources
  * @param string $type_echange Type de l'échange
  * @param bool   $only_active  Seulement la source active
  *
  * @return CExchangeSource
  */
 static function get($name, $type = null, $override = false, $type_echange = null, $only_active = true)
 {
     $cache = new Cache(__METHOD__, func_get_args(), Cache::INNER);
     if ($cache->exists()) {
         return $cache->get();
     }
     $exchange_classes = self::getExchangeClasses();
     foreach ($exchange_classes as $_class) {
         /** @var CExchangeSource $exchange_source */
         $exchange_source = new $_class();
         if (isset(self::$typeToClass[$type])) {
             $classname = self::$typeToClass[$type];
             if ($classname != $exchange_source->_class) {
                 continue;
             }
         }
         if ($only_active) {
             $exchange_source->active = 1;
         }
         $exchange_source->name = $name;
         $exchange_source->loadMatchingObject();
         if ($exchange_source->_id) {
             $exchange_source->_wanted_type = $type;
             $exchange_source->_allowed_instances = self::getObjects($name, $type, $type_echange);
             if ($exchange_source->role != CAppUI::conf("instance_role")) {
                 if (!$override) {
                     $incompatible_source = new $exchange_source->_class();
                     $incompatible_source->name = $exchange_source->name;
                     $incompatible_source->_incompatible = true;
                     CAppUI::displayAjaxMsg("CExchangeSource-_incompatible", UI_MSG_ERROR);
                     return $incompatible_source;
                 }
                 $exchange_source->_incompatible = true;
             }
             return $cache->put($exchange_source, false);
         }
     }
     $source = new CExchangeSource();
     if (isset(self::$typeToClass[$type])) {
         $source = new self::$typeToClass[$type]();
     }
     $source->name = $name;
     $source->type_echange = $type_echange;
     $source->_wanted_type = $type;
     $source->_allowed_instances = self::getObjects($name, $type, $type_echange);
     return $cache->put($source, false);
 }
<?php

/**
 * Define master idex missing
 *
 * @category EAI
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  SVN: $Id:$
 * @link     http://www.mediboard.org
 */
CCanDo::checkAdmin();
$exchange_guid = CValue::get("exchange_guid");
if (!$exchange_guid) {
    CAppUI::displayAjaxMsg("Pas d'objet passé en paramètre");
    CApp::rip();
}
/** @var CExchangeDataFormat $exchange */
$exchange = CMbObject::loadFromGuid($exchange_guid);
$master_IPP_missing = false;
$pattern = "===IPP_MISSING===";
if (!CValue::read($receiver->_configs, "send_not_master_IPP") && strpos($exchange->_message, $pattern) !== false) {
    $master_IPP_missing = true;
}
$master_NDA_missing = false;
$pattern = "===NDA_MISSING===";
if (!CValue::read($receiver->_configs, "send_not_master_NDA") && strpos($exchange->_message, $pattern) !== false) {
    $master_NDA_missing = true;
}
$patient = null;
Esempio n. 18
0
$object_guid = CValue::post("object_guid");
$object = CMbObject::loadFromGuid($object_guid);
/** @var $exchange_source CSourceSMTP */
$exchange_source = CExchangeSource::get("mediuser-" . CMediusers::get()->_id, "smtp");
$exchange_source->init();
if (CAppUI::pref('hprim_med_header')) {
    $body = $object->makeHprimHeader($exchange_source->email, $email) . "\n" . $body;
}
try {
    $exchange_source->setRecipient($email, $nom);
    $exchange_source->setSubject($subject);
    $exchange_source->setBody(nl2br($body));
    switch ($object->_class) {
        case "CCompteRendu":
            /** @var $object CCompteRendu */
            $object->makePDFpreview(true);
            $file = $object->_ref_file;
            $exchange_source->addAttachment($file->_file_path, $file->file_name);
            break;
        case "CFile":
            /** @var $object CFile */
            $exchange_source->addAttachment($object->_file_path, $object->file_name);
    }
    $exchange_source->send();
    $exchange_source->createUserMail(CAppUI::$user->_id, $object);
    CAppUI::displayAjaxMsg("Message envoyé");
} catch (phpmailerException $e) {
    CAppUI::displayAjaxMsg($e->errorMessage(), UI_MSG_WARNING);
} catch (CMbException $e) {
    $e->stepAjax();
}
Esempio n. 19
0
 /**
  * Method testing if we able to connect to server ES
  *
  * @param CGRoups $group The group
  *
  * @return void
  */
 function testConnection($group)
 {
     try {
         $this->createClient();
         $index = $this->loadIndex();
         $search = new \Elastica\Search($this->_client);
         $search->addIndex($index);
         $this->_client->getCluster();
     } catch (Exception $e) {
         if (CAppUI::conf("search active_handler active_handler_search", $group)) {
             CAppUI::displayAjaxMsg("Le serveur de recherche n'est pas connecté", UI_MSG_ERROR);
         } else {
             CAppUI::displayAjaxMsg("Le serveur de recherche n'est pas configuré, veuillez prendre contact avec un administrateur", UI_MSG_ERROR);
         }
     }
 }