Пример #1
1
 /**
  * Set the hash for the user mails
  *
  * @return bool
  */
 protected function setUserMailHash()
 {
     $ds = CSQLDataSource::get("std");
     $mails = $ds->loadList("SELECT m.user_mail_id, m.account_class, m.account_id, m.from, m.to, m.subject, c.content FROM user_mail as m, content_html as c WHERE m.account_class IS NOT NULL AND m.account_id IS NOT NULL AND m.text_html_id = c.content_id ORDER BY m.user_mail_id DESC;");
     if (count($mails)) {
         $values = array();
         foreach ($mails as $_mail) {
             $data = "==FROM==\n" . $_mail['from'] . "\n==TO==\n" . $_mail['to'] . "\n==SUBJECT==\n" . $_mail['subject'] . "\n==CONTENT==\n" . $_mail['content'];
             $hash = CMbSecurity::hash(CMbSecurity::SHA256, $data);
             $values[] = '(' . $_mail['user_mail_id'] . ', ' . $_mail['account_id'] . ', \'' . $_mail['account_class'] . "', '{$hash}')";
         }
         $mails = $ds->loadList("SELECT m.user_mail_id, m.account_class, m.account_id, m.from, m.to, m.subject, c.content FROM user_mail AS m, content_any AS c WHERE m.account_class IS NOT NULL AND m.account_id IS NOT NULL AND m.text_html_id IS NULL AND m.text_plain_id = c.content_id ORDER BY m.user_mail_id DESC;");
         foreach ($mails as $_mail) {
             $data = "==FROM==\n" . $_mail['from'] . "\n==TO==\n" . $_mail['to'] . "\n==SUBJECT==\n" . $_mail['subject'] . "\n==CONTENT==\n" . $_mail['content'];
             $hash = CMbSecurity::hash(CMbSecurity::SHA256, $data);
             $values[] = '(' . $_mail['user_mail_id'] . ', ' . $_mail['account_id'] . ', \'' . $_mail['account_class'] . "', '{$hash}')";
         }
         $query = "INSERT INTO `user_mail` (`user_mail_id`, `account_id`, `account_class`, `hash`) VALUES " . implode(', ', $values) . " ON DUPLICATE KEY UPDATE `hash` = VALUES(`hash`);";
         $ds->query($query);
         if ($msg = $ds->error()) {
             CAppUI::stepAjax($msg, UI_MSG_WARNING);
             return false;
         }
     }
     return true;
 }
 /**
  * Constructor
  *
  * @param string $className Class name
  * @param int    $objectKey Object key name
  */
 function CDoObjectAddEdit($className, $objectKey = null)
 {
     if (CAppUI::conf("readonly")) {
         CAppUI::stepAjax("Mode-readonly-title", UI_MSG_ERROR);
         return;
     }
     global $m;
     $this->className = $className;
     $this->postRedirect = null;
     $this->redirect = "m={$m}";
     $this->redirectStore = null;
     $this->redirectError = null;
     $this->redirectDelete = null;
     $this->createMsg = CAppUI::tr("{$className}-msg-create");
     $this->modifyMsg = CAppUI::tr("{$className}-msg-modify");
     $this->deleteMsg = CAppUI::tr("{$className}-msg-delete");
     $this->request =& $_POST;
     $this->_logIt = true;
     // @todo : à supprimer cf déplacement dans le doBind()
     $this->_obj = new $this->className();
     $this->_old = new $this->className();
     $this->onAfterInstanciation();
     // Lancer ceci apres chaque instanciation de _obj et _old !!
     $this->objectKey = $objectKey ? $objectKey : $this->_obj->_spec->key;
     $this->objectKeys = $this->objectKey . "s";
 }
 public function stepAjax($type = UI_MSG_WARNING)
 {
     $args = func_get_args();
     $msg = CAppUI::tr($this->getMessage(), array_slice($args, 1));
     CAppUI::$localize = false;
     CAppUI::stepAjax($msg, $type);
     CAppUI::$localize = true;
 }
Пример #4
0
 /**
  * @see parent::send()
  */
 function send(CCompteRendu $docItem)
 {
     if ($xml = CDMPAntaresXML::generateXML($docItem)) {
         return true;
     }
     CAppUI::stepAjax("Document non valide", UI_MSG_ERROR);
     return false;
 }
Пример #5
0
/**
 * import the csv firstname file
 *
 * @param string $targetPath filepath
 * @param int    $start      start from
 * @param int    $count      step of import
 *
 * @return void
 */
function importFile($targetPath, $start, $count)
{
    $fp = fopen($targetPath, 'r');
    //0 = first line
    if ($start == 0) {
        $start++;
    }
    $line_nb = 0;
    while ($line = fgetcsv($fp, null, ";")) {
        if ($line_nb >= $start && $line_nb < $start + $count) {
            $found = false;
            $fn = CMbString::removeDiacritics(trim($line[0]));
            $sex = trim($line[1]);
            $language = CMbString::removeDiacritics(trim($line[2]));
            if ($sex == "m,f" || $sex == "f,m") {
                $sex = "u";
            }
            $firstname = new CFirstNameAssociativeSex();
            $firstname->firstname = $fn;
            $firstname->language = $language;
            $firstname->loadMatchingObjectEsc();
            if ($firstname->_id) {
                // found
                $found = true;
                if ($sex != $firstname->sex) {
                    $firstname->sex = "u";
                }
            } else {
                // not found
                $firstname->sex = $sex;
            }
            // store & message
            if ($msg = $firstname->store()) {
                CAppUI::stepAjax($msg, UI_MSG_WARNING);
            } else {
                if ($found == true) {
                    CAppUI::stepAjax("prénom <strong>{$fn}</strong>, mis à jour <strong>[{$firstname->sex}]</strong>");
                } else {
                    CAppUI::stepAjax("prénom <strong>{$fn}</strong>, ajouté <strong>[{$firstname->sex}]</strong>");
                }
            }
        }
        $line_nb++;
    }
    return;
}
 /**
  * @see parent::send()
  */
 function send(CCompteRendu $docItem)
 {
     $object = $docItem->loadTargetObject();
     if ($object instanceof CConsultAnesth) {
         $object = $object->loadRefConsultation();
     }
     if ($object instanceof CPatient) {
         CAppUI::stepAjax("Impossible d'ajouter un document lié directement à un patient", UI_MSG_ERROR);
     }
     $receiver_hl7v3 = new CReceiverHL7v3();
     $receiver_hl7v3->actif = 1;
     $receiver_hl7v3->group_id = CGroups::loadCurrent()->_id;
     /** @var CReceiverHL7v3[] $receivers */
     $receivers = $receiver_hl7v3->loadMatchingList();
     foreach ($receivers as $_receiver) {
         $request = $_receiver->sendEventProvideAndRegisterDocumentSetRequest($docItem);
         mbTrace($request);
     }
 }
Пример #7
0
/**
 * Fonction de construction du cache d'info des durées
 * d'hospi et d'interv
 *
 * @param string $tableName   Nom de la table de cache
 * @param string $tableFields Champs de la table de cache
 * @param array  $queryFields Liste des champs du select
 * @param string $querySelect Chaine contenant les éléments SELECT à utiliser
 * @param array  $queryWhere  Chaine contenant les éléments WHERE à utiliser
 *
 * @return void
 */
function buildPartialTables($tableName, $tableFields, $queryFields, $querySelect, $queryWhere)
{
    $ds = CSQLDataSource::get("std");
    $joinedFields = join(", ", $queryFields);
    // Intervale de temps
    $intervalle = CValue::get("intervalle");
    switch ($intervalle) {
        case "month":
            $deb = CMbDT::date("-1 month");
            break;
        case "6month":
            $deb = CMbDT::date("-6 month");
            break;
        case "year":
            $deb = CMbDT::date("-1  year");
            break;
        default:
            $deb = CMbDT::date("-10 year");
    }
    $fin = CMbDT::date();
    // Suppression si existe
    $drop = "DROP TABLE IF EXISTS `{$tableName}`";
    $ds->exec($drop);
    // Création de la table partielle
    $create = "CREATE TABLE `{$tableName}` (" . "\n`chir_id` int(11) unsigned NOT NULL default '0'," . "{$tableFields}" . "\n`ccam` varchar(255) NOT NULL default ''," . "\nKEY `chir_id` (`chir_id`)," . "\nKEY `ccam` (`ccam`)" . "\n) /*! ENGINE=MyISAM */;";
    $ds->exec($create);
    // Remplissage de la table partielle
    $query = "INSERT INTO `{$tableName}` ({$joinedFields}, `chir_id`, `ccam`)\r\n    SELECT {$querySelect}\r\n    operations.chir_id,\r\n    operations.codes_ccam AS ccam\r\n    FROM operations\r\n    LEFT JOIN users\r\n    ON operations.chir_id = users.user_id\r\n    LEFT JOIN plagesop\r\n    ON operations.plageop_id = plagesop.plageop_id\r\n    WHERE operations.annulee = '0'\r\n    {$queryWhere}\r\n    AND operations.date BETWEEN '{$deb}' AND '{$fin}'\r\n    GROUP BY operations.chir_id, ccam\r\n    ORDER BY ccam;";
    $ds->exec($query);
    CAppUI::stepAjax("Nombre de valeurs pour la table '{$tableName}': " . $ds->affectedRows(), UI_MSG_OK);
    // Insert dans la table principale si vide
    if (!$ds->loadResult("SELECT COUNT(*) FROM temps_op")) {
        $query = "INSERT INTO temps_op ({$joinedFields}, `chir_id`, `ccam`)\r\n      SELECT {$joinedFields}, `chir_id`, `ccam`\r\n      FROM {$tableName}";
        $ds->exec($query);
    } else {
        $query = "UPDATE temps_op, {$tableName} SET ";
        foreach ($queryFields as $queryField) {
            $query .= "\ntemps_op.{$queryField} = {$tableName}.{$queryField}, ";
        }
        $query .= "temps_op.chir_id = {$tableName}.chir_id" . "\nWHERE temps_op.chir_id = {$tableName}.chir_id" . "\nAND temps_op.ccam = {$tableName}.ccam";
        $ds->exec($query);
    }
}
Пример #8
0
/**
 * Parse le fichier et remplit la table correspondante
 *
 * @param string $file  File path
 * @param string $table Table name
 *
 * @return void
 */
function addFileIntoDB($file, $table)
{
    $reussi = 0;
    $echoue = 0;
    $ds = CSQLDataSource::get("cdarr");
    $handle = fopen($file, "r");
    // Ne pas utiliser fgetcsv, qui refuse de prendre en compte les caractères en majusucules accentués (et d'autres caractères spéciaux)
    while ($line = fgets($handle)) {
        $line = str_replace("'", "\\'", $line);
        $datas = explode("|", $line);
        $query = "INSERT INTO {$table} VALUES('" . implode("','", $datas) . "')";
        $ds->exec($query);
        if ($msg = $ds->error()) {
            $echoue++;
        } else {
            $reussi++;
        }
    }
    fclose($handle);
    CAppUI::stepAjax("ssr-import-cdarr-report", UI_MSG_OK, $file, $table, $reussi, $echoue);
}
Пример #9
0
 /**
  * Load unread messages
  *
  * @param null $user_id user to load, null = current
  *
  * @return CUserMessageDest[]
  */
 static function loadNewMessages($user_id = null)
 {
     $dests = array();
     if (CModule::getActive("messagerie")) {
         $dest = new self();
         if ($dest->_ref_module->mod_version < 0.3) {
             CAppUI::stepAjax("CModule%s-msg-pls_update_module", UI_MSG_WARNING, $dest->_ref_module->mod_name);
             return $dests;
         }
         $user = CMediusers::get($user_id);
         $where = array();
         $where["to_user_id"] = " = '{$user->_id}'";
         $where["datetime_sent"] = " IS NOT NULL";
         $where["datetime_read"] = " IS NULL";
         /** @var CUserMessageDest[] $dests */
         $dests = $dest->loadList($where);
         foreach ($dests as $_dest) {
             $_dest->loadRefFwd();
         }
     }
     return $dests;
 }
Пример #10
0
function addFileIntoDB($file, $table)
{
    $reussi = 0;
    $echoue = 0;
    $ds = CSQLDataSource::get("ccamV2");
    $handle = fopen($file, "r");
    $values = array();
    $batch = 50;
    // Ne pas utiliser fgetcsv, qui refuse de prendre en compte les caractères en majusucules accentués (et d'autres caractères spéciaux)
    while ($line = fgets($handle)) {
        $line = str_replace("'", "\\'", $line);
        $values[] = explode("|", $line);
        if (count($values) == $batch) {
            insertValues($ds, $table, $values, $echoue, $reussi);
            $values = array();
        }
    }
    if (count($values)) {
        insertValues($ds, $table, $values, $echoue, $reussi);
    }
    CAppUI::stepAjax("Import du fichier {$file} dans la table {$table} : {$reussi} lignes ajoutée(s), {$echoue} échouée(s)", UI_MSG_OK);
    fclose($handle);
}
Пример #11
0
 function printFile($file)
 {
     // Test de la commande smbclient
     exec("whereis smbclient", $ret);
     if (preg_match("@\\/smbclient@", $ret[0]) == 0) {
         CAppUI::stepAjax("La commande smbclient n'est pas disponible", UI_MSG_ERROR);
     }
     if (file_get_contents($file->_file_path) === false) {
         CAppUI::stepAjax("Impossible d'accéder au PDF", UI_MSG_ERROR);
     }
     // Construction de l'uri
     $uri = escapeshellarg("//{$this->hostname}/{$this->printer_name}") . " ";
     if ($this->password) {
         $uri .= escapeshellarg($this->password);
     }
     $uri .= " -c " . escapeshellarg('print ' . escapeshellarg($file->_file_path)) . " ";
     if ($this->username) {
         $uri .= "-U " . escapeshellarg($this->username) . " ";
     }
     if ($this->workgroup) {
         $uri .= "-W " . escapeshellarg($this->workgroup) . " ";
     }
     if (!$this->password) {
         $uri .= "-N";
     }
     exec("smbclient {$uri}", $res);
     if (count($res)) {
         $mess = "";
         foreach ($res as $_res) {
             $mess .= $_res . "\n";
         }
         CAppUI::stepAjax("Impression échouée \n" . $mess, UI_MSG_ERROR);
     } else {
         CAppUI::stepAjax("Impression réussie", UI_MSG_OK);
     }
 }
Пример #12
0
<?php

/**
 * $Id: httpreq_do_add_insee.php 19219 2013-05-21 12:26:07Z phenxdesign $
 *
 * @package    Mediboard
 * @subpackage Patients
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 19219 $
 */
CCanDo::checkAdmin();
$sourcePath = "modules/dPpatients/INSEE/insee.tar.gz";
$targetDir = "tmp/insee";
$targetPath = "tmp/insee/insee.sql";
// Extract the SQL dump
if (null == ($nbFiles = CMbPath::extract($sourcePath, $targetDir))) {
    CAppUI::stepAjax("Erreur, impossible d'extraire l'archive", UI_MSG_ERROR);
}
CAppUI::stepAjax("Extraction de {$nbFiles} fichier(s)", UI_MSG_OK);
$ds = CSQLDataSource::get("INSEE");
if (null == ($lineCount = $ds->queryDump($targetPath, true))) {
    $msg = $ds->error();
    CAppUI::stepAjax("Erreur de requête SQL: {$msg}", UI_MSG_ERROR);
}
CAppUI::stepAjax("import effectué avec succès de {$lineCount} lignes", UI_MSG_OK);
////////// Smarty templates
// DO NOT use CMbPath::removed because it must be used in the installer
$templates = array_merge(glob("tmp/templates_c/*/*/*/*/*"), glob("tmp/templates_c/*/*/*/*"), glob("tmp/templates_c/*/*/*"));
foreach ($templates as $_template) {
    if (is_file($_template)) {
        unlink($_template);
    }
}
$template_dirs = array_merge(glob("tmp/templates_c/*/*/*/*", GLOB_ONLYDIR), glob("tmp/templates_c/*/*/*", GLOB_ONLYDIR), glob("tmp/templates_c/*/*", GLOB_ONLYDIR));
foreach ($template_dirs as $_dir) {
    rmdir($_dir);
}
CAppUI::stepAjax("template-cache-removed", UI_MSG_OK, count($templates));
////////// Module specific removals
foreach (glob("modules/*/empty_shared_memory.php") as $script) {
    include $script;
}
// Remove locales, at the end because otherwise, next message aren't translated
foreach (glob("locales/*", GLOB_ONLYDIR) as $localeDir) {
    $localeName = basename($localeDir);
    $sharedName = "locales-{$localeName}";
    if (!SHM::get("{$sharedName}-" . CAppUI::LOCALES_PREFIX)) {
        CAppUI::stepAjax("Locales-shm-none", UI_MSG_OK, $localeName);
        continue;
    }
    if (!SHM::remKeys("{$sharedName}-*")) {
        CAppUI::stepAjax("Locales-shm-rem-ko", UI_MSG_WARNING, $localeName);
        continue;
    }
    CAppUI::stepAjax("Locales-shm-rem-ok", UI_MSG_OK, $localeName);
}
    $where["functions_mediboard.group_id"] = "= '{$group_id}'";
    $users_all = $user->loadList($where, null, null, null, $ljoin);
    /** @var $users CUser[] */
    $users = array_diff_key($users_all, $users_ldap);
    $users = array_slice($users, $start, $count);
    $count = $count_no_associate = $count_associate = 0;
    foreach ($users as $_user) {
        try {
            $source_ldap = CLDAP::bind($_user, $ldaprdn, $ldappass);
            $_user = CLDAP::searchAndMap($_user, $source_ldap, $source_ldap->_ldapconn, $_user->user_username, null);
        } catch (CMbException $e) {
            $e->stepAjax();
        }
        if ($_user->_count_ldap != 0) {
            $count_associate++;
        }
        if ($_user->_count_ldap == 0) {
            CAppUI::stepAjax("'{$_user->_view}' / '{$_user->user_username}' non associé", UI_MSG_WARNING);
            $count_no_associate++;
        }
        $count++;
    }
    if ($count == 0) {
        echo "<script type='text/javascript'>stop=true;</script>";
    }
    $next = $start + $count_no_associate;
    CAppUI::stepAjax("{$count_associate} comptes associés");
    CAppUI::stepAjax("{$count_no_associate} comptes non associés", UI_MSG_WARNING);
    CValue::setSession("start", $next);
    CAppUI::stepAjax("On continuera au n° {$next} / " . count($users) . " restants");
}
Пример #15
0
    $objects_id = explode("-", $objects_id);
}
$user = CMediusers::get();
CMbArray::removeValue("", $objects_id);
$objects = array();
$result = null;
$checkMerge = null;
$statuses = array();
$merge_type = null;
if (class_exists($objects_class) && count($objects_id)) {
    foreach ($objects_id as $object_id) {
        /** @var CMbObject $object */
        $object = new $objects_class();
        $merge_type = $object->_spec->merge_type;
        if ($merge_type == 'none') {
            CAppUI::stepAjax("Merging_%sclass_is_forbidden_by_spec", UI_MSG_ERROR, CAppUI::tr($object->_class));
        }
        // the CMbObject is loaded
        if (!$object->load($object_id)) {
            CAppUI::setMsg("Chargement impossible de l'objet [{$object_id}]", UI_MSG_ERROR);
            continue;
        }
        $object->loadView();
        $object->loadAllFwdRefs(true);
        $object->_selected = false;
        $object->_disabled = false;
        $objects[] = $object;
    }
    // Default préselection of first object
    $_selected = reset($objects);
    // selection of the first CSejour or CPatient with an ext ID
Пример #16
0
            case "rpps":
                $rpps = $medecin->rpps;
                $medecin = $sibling;
                $medecin->rpps = $rpps;
        }
        $updates++;
    }
    // Sauvegarde
    $medecin->repair();
    if ($msg = $medecin->store()) {
        trigger_error("Error storing {$medecin->nom} {$medecin->prenom} ({$medecin->cp}) : {$msg}", E_USER_WARNING);
        $errors++;
    }
    $medecin->updateFormFields();
    $medecins[] = $medecin;
}
$chrono->stop();
CAppUI::stepAjax("Etape {$step} \n{$errors} erreurs d'enregistrements", $errors ? UI_MSG_OK : UI_MSG_ALERT);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("verbose", CValue::get("verbose"));
$smarty->assign("xpath_screwed", $xpath_screwed);
$smarty->assign("step", $step);
$smarty->assign("from", $from);
$smarty->assign("to", $to);
$smarty->assign("medecins", $medecins);
$smarty->assign("chrono", $chrono);
$smarty->assign("updates", $updates);
$smarty->assign("errors", $errors);
$smarty->assign("last_page", $last_page);
$smarty->display("import_medecin.tpl");
Пример #17
0
 * @subpackage messagerie
 * @version $Revision$
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 */
CCanDo::checkRead();
$user = CMediusers::get();
$mail_id = CValue::get("mail_id");
$log_pop = new CSourcePOP();
$log_pop->name = "user-pop-" . $user->_id;
$log_pop->loadMatchingObject();
if (!$log_pop) {
    CAppUI::stepAjax("Source POP indisponible", UI_MSG_ERROR);
}
if (!$mail_id) {
    CAppUI::stepAjax("CSourcePOP-error-mail_id", UI_MSG_ERROR);
}
//pop init
$pop = new CPop($log_pop);
$pop->open();
//mail
$mail = new CUserMail();
$head = $pop->header($mail_id);
$content = $pop->getFullBody($_mail, false, false, true);
$hash = $mail_unseen->makeHash($head, $content);
$mail->loadMatchingFromHash($hash);
if ($mail->_id && !$mail->text_plain_id) {
    $mail->setHeaderFromSource($head);
    $mail->setContentFromSource($pop->getFullBody($_mail, false, false, true));
    $mail->date_read = CMbDT::dateTime();
    $mail->user_id = $user->_id;
Пример #18
0
    foreach ($_modele->childNodes as $_node) {
        if (in_array($_node->nodeName, CCompteRendu::$fields_import_export)) {
            $modele->{$_node->nodeName} = $_node->nodeValue;
        }
    }
    $modele->nom = utf8_decode($modele->nom);
    // Mapping de l'entête, pieds de page, introduction, conclusion
    foreach ($components as $_component) {
        if ($modele->{$_component}) {
            $modele->{$_component} = $modeles_ids[$modele->{$_component}];
        }
    }
    // Recherche de la catégorie
    $cat = utf8_decode($_modele->getAttribute("cat"));
    if ($cat) {
        $categorie = new CFilesCategory();
        $categorie->nom = $cat;
        if (!$categorie->loadMatchingObject()) {
            $categorie->store();
        }
        $modele->file_category_id = $categorie->_id;
    }
    if ($msg = $modele->store()) {
        CAppUI::stepAjax($modele->nom . " - " . $msg, UI_MSG_ERROR);
        continue;
    }
    CAppUI::stepAjax($modele->nom . " - " . CAppUI::tr("CCompteRendu-msg-create"), UI_MSG_OK);
    // On garde la référence entre l'id provenant du xml et l'id en base
    $modeles_ids[$_modele->getAttribute("modele_id")] = $modele->_id;
}
CAppUI::js("window.opener.getForm('filterModeles').onsubmit()");
switch ($cache_status) {
    case "empty":
        CAppUI::stepAjax("ConfigModel-shm-none", UI_MSG_OK);
        break;
    case "dirty":
        CAppUI::stepAjax("ConfigModel-shm-ko", UI_MSG_WARNING);
        break;
    case "ok":
        CAppUI::stepAjax("ConfigModel-shm-ok", UI_MSG_OK);
        break;
}
////////// Configuration values
$cache_status = CConfiguration::getValuesCacheStatus();
switch ($cache_status) {
    case "empty":
        CAppUI::stepAjax("ConfigValues-shm-none", UI_MSG_OK);
        break;
    case "dirty":
        CAppUI::stepAjax("ConfigValues-shm-ko", UI_MSG_WARNING);
        break;
    case "ok":
        CAppUI::stepAjax("ConfigValues-shm-ok", UI_MSG_OK);
        break;
}
// Smarty templates
$templates = glob("tmp/templates_c/*/*");
CAppUI::stepAjax("template-cache-ok", UI_MSG_OK, count($templates));
// Module specific checkings
foreach (glob("modules/*/check_shared_memory.php") as $script) {
    include $script;
}
Пример #20
0
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
$step = CValue::get("step", 0);
$aff_pers = new CAffectationPersonnel();
$where = array();
$where["object_class"] = "= 'CPlageOp'";
$affs = $aff_pers->loadList($where, null, "{$step},1000");
/**@var $_aff CAffectationPersonnel */
foreach ($affs as $_aff) {
    $plage = $_aff->loadRefObject();
    $ops = $plage->loadBackIds("operations");
    foreach ($ops as $_op) {
        $affectation = new CAffectationPersonnel();
        $whereAff = array();
        $whereAff["personnel_id"] = "= '{$_aff->personnel_id}'";
        $whereAff["object_class"] = "= 'COperation'";
        $whereAff["object_id"] = "= '{$_op}'";
        $whereAff["parent_affectation_id"] = "IS NULL";
        if ($affectation->loadObject($whereAff)) {
            $affectation->parent_affectation_id = $_aff->_id;
            $msg = $affectation->store();
            CAppUI::stepAjax($msg ? $msg : "Affectation modifiée", $msg ? UI_MSG_ERROR : UI_MSG_OK);
        }
    }
}
CAppui::js('if (' . count($affs) . ' > 0) { 
  $V(getForm("Configure").step, parseInt($V(getForm("Configure").step))+1000);
  affUpdate();
 }');
Пример #21
0
$destination_guid = CValue::get("destination_guid");
$name = CValue::get("file_name");
$category_id = CValue::get("category_id");
$allowed = array("CFile", "CCompteRendu");
if (!in_array($file_class, $allowed)) {
    CAppUI::stepAjax("CFile-msg-not_allowed_object_to_move", UI_MSG_ERROR);
}
/** @var CFile|CCompteRendu $file */
$file = new $file_class();
$file->load($file_id);
$file->file_category_id = $category_id && $category_id != $file->file_category_id ? $category_id : $file->file_category_id;
if ($file instanceof CFile) {
    $file->file_name = $name ? $name : $file->file_name;
}
$destination = CStoredObject::loadFromGuid($destination_guid);
if ($file->object_id == $destination->_id && $file->object_class == $destination->_class) {
    CAppUI::stepAjax("CFile-msg-from_equal_to", UI_MSG_ERROR);
}
$file->setObject($destination);
// check category
$cat = new CFilesCategory();
$cat->load($file->file_category_id);
if ($cat->class && $cat->class != $destination->_class) {
    $file->file_category_id = "";
}
if ($msg = $file->store()) {
    CAppUI::setMsg($msg, UI_MSG_ERROR);
} else {
    CAppUI::setMsg("CFile-msg-moved");
}
echo CAppUI::getMsg();
Пример #22
0
    $where["exchange_hl7v2.date_production"] = "< '{$date_max}'";
    $where["exchange_hl7v2.message_content_id"] = "IS NOT NULL";
    $where["exchange_hl7v2.acquittement_content_id"] = "IS NOT NULL";
    $count = $exchange_hl7v2->countList($where);
    CAppUI::stepAjax("CExchangeHL7v2-msg-purge_count", UI_MSG_OK, $count);
    return;
}
// Filtre sur les enregistrements
$content_tabular = new CContentTabular();
$count = 0;
$count += deleteContentAndUpdateExchange($content_tabular, "message_content_id", $date_max, $max);
$count += deleteContentAndUpdateExchange($content_tabular, "acquittement_content_id", $date_max, $max);
if ($count) {
    echo "<script type='text/javascript'>Echange.purge();</script>";
}
CAppUI::stepAjax("CExchangeHL7v2-msg-purged_count", UI_MSG_OK, $count, CMbDT::dateTime());
/**
 * Delete content and update exchange
 *
 * @param CContentTabular $content_tabular Content tabular
 * @param int             $type_content_id Content ID
 * @param date            $date_max        Date max
 * @param int             $max             Max exchange
 *
 * @return int
 */
function deleteContentAndUpdateExchange(CContentTabular $content_tabular, $type_content_id, $date_max, $max)
{
    $ds = $content_tabular->_spec->ds;
    // Récupère les content Tabulé
    $query = "SELECT cx.content_id\r\n            FROM content_tabular AS cx, exchange_hl7v2 AS ec\r\n            WHERE ec.`date_production` < '{$date_max}'\r\n            AND ec.{$type_content_id} = cx.content_id\r\n            LIMIT {$max};";
$type = CValue::get("type", 'check_entree');
$ds = CSQLDataSource::get("std");
$result = "";
switch ($type) {
    case 'check_entree':
        $message = " entrée(s) erronée(s)";
        $sql = "SELECT COUNT(*) AS total \n      FROM `sejour`\n      WHERE `sejour`.`entree` != IF(`sejour`.`entree_reelle`,`sejour`.`entree_reelle`,`sejour`.`entree_prevue`)";
        $result = $ds->loadResult($sql);
        break;
    case 'check_sortie':
        $message = " sortie(s) erronnée(s)";
        $sql = "SELECT COUNT(*) AS total \n      FROM `sejour`\n      WHERE `sejour`.`sortie` != IF(`sejour`.`sortie_reelle`,`sejour`.`sortie_reelle`,`sejour`.`sortie_prevue`)";
        $result = $ds->loadResult($sql);
        break;
    case 'fix_entree':
        $message = " entrée(s) corrigée(s)";
        $sql = "UPDATE `sejour` SET\n      `sejour`.`entree` = IF(`sejour`.`entree_reelle`,`sejour`.`entree_reelle`,`sejour`.`entree_prevue`)\n      WHERE `sejour`.`entree` != IF(`sejour`.`entree_reelle`,`sejour`.`entree_reelle`,`sejour`.`entree_prevue`)";
        $ds->query($sql);
        $result = $ds->affectedRows();
        break;
    case 'fix_sortie':
        $message = " sortie(s) corrigée(s)";
        $sql = "UPDATE `sejour` SET\n      `sejour`.`sortie` = IF(`sejour`.`sortie_reelle`,`sejour`.`sortie_reelle`,`sejour`.`sortie_prevue`)\n      WHERE `sejour`.`sortie` != IF(`sejour`.`sortie_reelle`,`sejour`.`sortie_reelle`,`sejour`.`sortie_prevue`)";
        $ds->query($sql);
        $result = $ds->affectedRows();
        break;
    default:
        CAppUI::stepAjax("Commande non reconnue", UI_MSG_ERROR);
}
CAppUI::stepAjax(CValue::first($result, "Aucune") . $message, $result ? UI_MSG_WARNING : UI_MSG_OK);
Пример #24
0
 * @subpackage System
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
// Check params
if (null == ($exchange_source_name = CValue::get("exchange_source_name"))) {
    CAppUI::stepAjax("CExchangeSource-error-noSourceName", UI_MSG_ERROR);
}
if (null == ($type_action = CValue::get("type_action"))) {
    CAppUI::stepAjax("CExchangeSource-error-noTestDefined", UI_MSG_ERROR);
}
/** @var CSyslogSource $exchange_source */
$exchange_source = CExchangeSource::get($exchange_source_name, "syslog", true, null, false);
if (!$exchange_source->_id) {
    CAppUI::stepAjax("CExchangeSource-error-unsavedParameters", UI_MSG_ERROR);
}
switch ($type_action) {
    case 'connection':
        if ($exchange_source->protocol == 'UDP') {
            try {
                $exchange_source->testUDPConnection();
                CAppUI::setMsg("common-msg-Successful connection", UI_MSG_OK);
            } catch (CMbException $e) {
                $e->stepAjax(UI_MSG_ERROR);
            }
        } else {
            try {
                $exchange_source->connect();
                CAppUI::setMsg("common-msg-Successful connection", UI_MSG_OK);
            } catch (CMbException $e) {
Пример #25
0
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Patients
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
$medecin_id = CValue::get("medecin_id");
$medecin = new CMedecin();
$medecin->load($medecin_id);
if (!$medecin || !$medecin->_id) {
    CAppUI::stepAjax('common-error-Invalid object', UI_MSG_ERROR);
}
$smarty = new CSmartyDP();
$smarty->assign("medecin", $medecin);
$smarty->assign("date", CMbDT::date());
$smarty->display("print_medecin.tpl");
Пример #26
0
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @link     http://www.mediboard.org */
CPasswordKeeper::checkHTTPS();
CCanDo::checkAdmin();
$password_keeper_id = CValue::postOrSession("password_keeper_id");
$_passphrase = CValue::post("passphrase");
$deletion = CValue::post("deletion");
$user = CMediusers::get();
$keeper = new CPasswordKeeper();
$keeper->load($password_keeper_id);
if ($keeper->_id && $keeper->user_id != $user->_id) {
    $msg = "Vous n'avez pas droit d'accéder à ce trousseau.";
    CAppUI::stepAjax($msg, UI_MSG_ERROR);
}
// Second passage, après avoir saisi la phrase de passe
if ($keeper->_id && $_passphrase) {
    if (!$keeper->testSample($_passphrase)) {
        $msg = "Phrase de passe incorrecte.";
        CAppUI::stepAjax($msg, UI_MSG_ERROR);
    }
    // Ecrit la phrase de passe en session
    CValue::setSessionAbs("passphrase", $_passphrase);
}
$smarty = new CSmartyDP();
$smarty->assign("keeper", $keeper);
$smarty->assign("user", $user);
$smarty->assign("_passphrase", $_passphrase);
$smarty->assign("deletion", $deletion);
$smarty->display("inc_edit_keeper.tpl");
Пример #27
0
            if ($sejour->sortie_reelle) {
                $sejour->sortie_reelle = CMbDT::dateTime("+4 HOURS", $sejour->entree);
            }
            /* TODO Supprimer ceci après l'ajout des times picker */
            $sejour->_hour_entree_prevue = null;
            $sejour->_min_entree_prevue = null;
            $sejour->_hour_sortie_prevue = null;
            $sejour->_min_sortie_prevue = null;
        } elseif ($sejour->type == "comp") {
            $sejour->sortie_prevue = CMbDT::dateTime("+72 HOURS", $sejour->entree);
            if ($sejour->sortie_reelle) {
                $sejour->sortie_reelle = CMbDT::dateTime("+72 HOURS", $sejour->entree);
            }
            /* TODO Supprimer ceci après l'ajout des times picker */
            $sejour->_hour_entree_prevue = null;
            $sejour->_min_entree_prevue = null;
            $sejour->_hour_sortie_prevue = null;
            $sejour->_min_sortie_prevue = null;
        }
        if ($msg = $sejour->store()) {
            CAppUI::stepAjax($msg, UI_MSG_ERROR);
        }
        break;
    default:
        CAppUI::stepAjax("L'évenement choisit n'est pas supporté", UI_MSG_ERROR);
}
CAppUI::stepAjax("Evenement effectué");
if ($callback) {
    CAppUI::callbackAjax($callback);
}
CApp::rip();
 protected static function _emptySHM($class, $key)
 {
     if (!SHM::get($key)) {
         CAppUI::stepAjax("{$class}-shm-none", UI_MSG_OK);
     } else {
         if (!SHM::rem($key)) {
             CAppUI::stepAjax("{$class}-shm-rem-ko", UI_MSG_WARNING);
         }
         CAppUI::stepAjax("{$class}-shm-rem-ok", UI_MSG_OK);
     }
 }
Пример #29
0
 * @package    Mediboard
 * @subpackage developpement
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
if (!class_exists("CMbCodeSniffer")) {
    CAppUI::stepMessage(UI_MSG_WARNING, "CMbCodeSniffer-error-PEAR_needed");
    return;
}
$file = CValue::get("file");
$file = str_replace(":", "/", $file);
// Has to be a file, not a directory
if (!is_file($file)) {
    CAppUI::stepAjax("sniff-file-nofile-error", UI_MSG_ERROR, $file);
}
$sniffer = new CMbCodeSniffer();
$sniffer->process($file);
$sniffer->report($file);
$stats = $sniffer->stat($file);
$errors = reset($sniffer->getFilesErrors());
$alerts = $sniffer->getFlattenAlerts();
// Cuz sniffer changes work dir but restores it at destruction
// Be aware that unset() won't call __destruct() anyhow
$sniffer->__destruct();
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("file", $file);
$smarty->assign("alerts", $alerts);
$smarty->assign("errors", $errors);
Пример #30
0
/**
 * import the patient file
 *
 * @param string   $file        path to the file
 * @param int      $start       start int
 * @param int      $count       number of iterations
 * @param resource $file_import file for report
 *
 * @return null
 */
function importFile($file, $start, $count, $file_import)
{
    $fp = fopen($file, 'r');
    $csv_file = new CCSVFile($fp);
    $csv_file->column_names = $csv_file->readLine();
    if ($start == 0) {
        $start++;
    } elseif ($start > 1) {
        $csv_file->jumpLine($start);
    }
    $group_id = CGroups::loadCurrent()->_id;
    $treated_line = 0;
    while ($treated_line < $count) {
        $treated_line++;
        $patient = new CPatient();
        $_patient = $csv_file->readLine(true);
        if (!$_patient) {
            CAppUI::stepAjax('Importation terminée', UI_MSG_OK);
            CApp::rip();
        }
        $patient->bind($_patient);
        $patient->loadFromIPP($group_id);
        if ($patient->_id) {
            $start++;
            continue;
        }
        $nom = $_patient['nom'] ? $_patient['nom'] : $_patient['nom_jeune_fille'];
        if (!$patient->nom) {
            if ($patient->nom_jeune_fille) {
                $patient->nom = $patient->nom_jeune_fille;
            } else {
                CMbDebug::log("Ligne #{$start} : Pas de nom");
                $start++;
                continue;
            }
        }
        $naissance = null;
        if ($patient->naissance) {
            $naissance = preg_replace('/(\\d{2})\\/(\\d{2})\\/(\\d{4})/', '\\3-\\2-\\1', $patient->naissance);
            $patient->naissance = $naissance;
        }
        $patient->repair();
        if (!$patient->naissance) {
            CMbDebug::log($_patient);
            CMbDebug::log("Ligne #{$start} : Date de naissance invalide ({$_patient['naissance']})");
            $start++;
            continue;
        }
        $patient->loadMatchingPatient();
        if (!$patient->_id) {
            $patient->bind($_patient);
            $patient->nom = $nom;
            $patient->naissance = $naissance;
            $patient->tel = preg_replace("/[^0-9]/", "", $patient->tel);
            $patient->tel_autre = preg_replace("/[^0-9]/", "", $patient->tel_autre);
            $patient->sexe = strtolower($patient->sexe);
            $patient->repair();
            if ($msg = $patient->store()) {
                CMbDebug::log($patient, null, true);
                CMbDebug::log("Ligne #{$start} :{$msg}");
                $start++;
                continue;
            }
        }
        $ipp = CIdSante400::getMatch($patient->_class, CPatient::getTagIPP($group_id), $patient->_IPP, $patient->_id);
        if ($ipp->_id && $ipp->id400 != $patient->_IPP) {
            CMbDebug::log("Ligne #{$start} : Ce patient possède déjà un IPP ({$ipp->id400})");
            $start++;
            continue;
        }
        if (!$ipp->_id) {
            if ($msg = $ipp->store()) {
                CMbDebug::log("Ligne #{$start} :{$msg}");
                $start++;
                continue;
            }
        }
        CAppUI::setMsg('CPatient-msg-create', UI_MSG_OK);
    }
    echo CAppUI::getMsg();
}