Пример #1
0
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage System
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
$start = CValue::get("start", 0);
CView::enforceSlave();
$filter = new CUserLog();
$filter->date = CValue::get("date", CMbDT::dateTime());
$filter->_date_max = CMbDT::dateTime($filter->date);
$filter->_date_min = CMbDT::dateTime("-1 week", $filter->date);
$filter->user_id = CValue::get("user_id");
$filter->ip_address = CValue::get("ip_address", "255.255.255.255");
$order_col = CValue::getOrSession("order_col", "date_max");
$order_way = CValue::getOrSession("order_way", "DESC");
$order_way_alt = $order_way == "ASC" ? "DESC" : "ASC";
$user = new CMediusers();
$listUsers = $user->loadUsers();
$where = array("ip_address IS NOT NULL AND ip_address != ''");
$where[] = "date >= '{$filter->_date_min}'";
$where[] = "date <= '{$filter->_date_max}'";
$where[] = "user_id " . CSQLDataSource::prepareIn(array_keys($listUsers), $filter->user_id);
$order = "{$order_col} {$order_way}";
$group = "ip_address";
 /**
  * Returns a field's value at the specified date
  * 
  * @param string $date  ISO Date
  * @param string $field Field name
  *
  * @return string
  */
 function getValueAtDate($date, $field)
 {
     return CUserLog::getObjectValueAtDate($this, $date, $field);
 }
 /**
  * Get date last checklist for a type
  *
  * @param CMbObject $object Object to get the check lists of
  * @param string    $type   type de checklist
  *
  * @return date
  */
 static function getDateLastChecklist(CMbObject $object, $type)
 {
     $date_last_checklist = null;
     $ljoin = array();
     $ljoin["daily_check_list_type"] = "daily_check_list_type.daily_check_list_type_id = daily_check_list.list_type_id";
     $where = array();
     $where["daily_check_list.object_class"] = " = '{$object->_class}'";
     $where["daily_check_list.object_id"] = " = '{$object->_id}'";
     $where["daily_check_list_type.type"] = " = '{$type}'";
     $checklist = new self();
     $checklist->loadObject($where, "date DESC", null, $ljoin);
     if ($checklist->_id) {
         if ($checklist->date_validate) {
             $date_last_checklist = $checklist->date_validate;
         } else {
             $log = new CUserLog();
             $log->object_id = $checklist->_id;
             $log->object_class = $checklist->_class;
             $log->loadMatchingObject("date DESC", "user_log_id");
             $date_last_checklist = $log->date;
         }
     }
     if (!$checklist->_id || !$date_last_checklist) {
         $date_last_checklist = $checklist->date;
     }
     return $date_last_checklist;
 }
foreach ($destockages as $code_cip => $_destockage) {
    $medicament = $medicaments[$code_cip];
    //$presentation = $destockages[$code_cip]["quantite"]/$medicament->nb_unite_presentation/$medicament->nb_presentation;
    $presentation = $destockages[$code_cip]["quantite"];
    if (!isset($destockages[$code_cip]["nb_produit"])) {
        $destockages[$code_cip]["nb_produit"] = 0;
    }
    $destockages[$code_cip]["nb_produit"] = $presentation;
    if (strstr($destockages[$code_cip]["nb_produit"], '.')) {
        $destockages[$code_cip]["nb_produit"] = ceil($destockages[$code_cip]["nb_produit"]);
    }
    $destockages[$code_cip]["stock"] = CProductStockService::getFromCode($code_cip, $service_id);
    if ($destockages[$code_cip]["stock"]) {
        $destockages[$code_cip]["stock"]->quantity -= $destockages[$code_cip]["nb_produit"];
        $stock = $destockages[$code_cip]["stock"];
        $log = new CUserLog();
        $where = array();
        $order = "date DESC";
        $where["object_id"] = " = '{$stock->_id}'";
        $where["object_class"] = " = '{$stock->_class}'";
        $where["date"] = " BETWEEN '{$date_min}' AND '{$date_max}'";
        $where["fields"] = " LIKE '%quantity%'";
        $destockages[$code_cip]["stock"]->_ref_logs = $log->loadList($where, $order);
        foreach ($destockages[$code_cip]["stock"]->_ref_logs as $log) {
            $log->loadRefsFwd();
        }
    } else {
        $product = new CProduct();
        $product->code = $code_cip;
        $product->category_id = CAppUI::conf('dPmedicament CBcbProduitLivretTherapeutique product_category_id');
        if ($product->loadMatchingObject()) {
Пример #5
0
/**
 * User logs graphic for system view
 *
 * @param datetime $startx    Datetime where the search starts
 * @param datetime $endx      Datetime where the search ends
 * @param string   $period    Aggregation period
 * @param string   $type      User log type to filter
 * @param int      $user_id   User ID to filter
 * @param string   $class     Class to filter
 * @param int      $object_id Object ID to filter
 *
 * @return array|bool
 */
function graphUserLogSystem($startx, $endx, $period, $type = null, $user_id = null, $class = null, $object_id = null)
{
    switch ($period) {
        case "hour":
            $step = "+1 HOUR";
            $period_format = "%d-%m-%Y %Hh";
            break;
        case "day":
            $step = "+1 DAY";
            $period_format = "%d-%m-%Y";
            break;
        case "week":
            $step = "+1 WEEK";
            $period_format = "%Y Sem. %W";
            break;
        case "month":
            $step = "+1 MONTH";
            $period_format = "%m-%Y";
            break;
        case "year":
            $step = "+1 YEAR";
            $period_format = "%Y";
            break;
        default:
            $step = "+1 HOUR";
            $period_format = "%d-%m-%Y %Hh";
    }
    $datax = array();
    $i = 0;
    for ($d = $startx; $d <= $endx; $d = CMbDT::dateTime($step, $d)) {
        $datax[] = array($i, CMbDT::format($d, $period_format));
        $i++;
    }
    // Compute a good spacement for label ticks
    $count_datax = count($datax);
    $space = 1;
    if ($count_datax > 35) {
        $space = round($count_datax / 35);
    }
    $logs = CUserLog::loadPeriodAggregation($startx, $endx, $period, $type, $user_id, $class, $object_id);
    if (!$logs) {
        return false;
    }
    $count = array();
    foreach ($datax as $x) {
        // Needed
        $count[$x[0]] = array($x[0], 0);
        foreach ($logs as $_log) {
            if ($x[1] == $_log['gperiod']) {
                $count[$x[0]] = array($x[0], $_log['count'], $_log['gperiod']);
            }
        }
    }
    // Label ticks spacement
    foreach ($datax as $i => &$x) {
        if ($i % $space) {
            $x[1] = '';
        }
    }
    $subtitle = CMbDT::format($endx, CAppUI::conf("longdate"));
    $options = array('subtitle' => utf8_encode($subtitle), 'xaxis' => array('labelsAngle' => 45, 'ticks' => $datax), 'yaxis' => array('min' => 0, 'autoscaleMargin' => 1), 'y2axis' => array('min' => 0, 'title' => utf8_encode('Quantité'), 'autoscaleMargin' => 1), 'grid' => array('verticalLines' => false), 'HtmlText' => false, 'spreadsheet' => array('show' => true, 'csvFileSeparator' => ';', 'decimalSeparator' => ','), 'mouse' => array('track' => true));
    $series = array();
    // Right axis (before in order the lines to be on top)
    $series[] = array('data' => $count, 'bars' => array('show' => true), 'yaxis' => 2);
    return array('series' => $series, 'options' => $options);
}
Пример #6
0
 /**
  * @see parent::send()
  */
 function send($docItem)
 {
     $this->initClientSOAP();
     $docItem->loadTargetObject();
     $object = $docItem->_ref_object;
     if ($object instanceof CConsultAnesth) {
         $object->loadRefConsultation();
         $object = $object->_ref_consultation;
     }
     $object->loadRefPraticien();
     $object->loadRefPatient();
     $object->_ref_praticien->loadRefSpecCPAM();
     if ($object instanceof CSejour) {
         $object->loadRefEtablissement();
         $sej_id = $object->_id;
         $doc_type = 29;
         $act_dateActe = CMbDT::date($object->entree_reelle);
         $act_dateValidationActe = CMbDT::date($object->entree_reelle);
         $etab_id = $object->_ref_group->_id;
         $etab_nom = $object->_ref_group->text;
     }
     if ($object instanceof COperation) {
         $object->_ref_sejour->loadRefEtablissement();
         $object->loadRefPlageOp();
         $sej_id = $object->sejour_id;
         $doc_type = 8;
         $act_dateActe = CMbDT::date($object->_datetime);
         $act_dateValidationActe = CMbDT::date($object->_datetime);
         $etab_id = $object->_ref_sejour->_ref_group->_id;
         $etab_nom = $object->_ref_sejour->_ref_group->text;
     }
     if ($object instanceof CConsultation) {
         $object->loadRefConsultAnesth();
         $act_dateActe = CMbDT::date($object->_ref_plageconsult->date);
         $act_dateValidationActe = CMbDT::date($object->_ref_plageconsult->date);
         if ($object->_ref_consult_anesth instanceof CConsultAnesth) {
             $object->_ref_consult_anesth->loadRefSejour();
             $sejour = $object->_ref_consult_anesth->_ref_sejour;
             $doc_type = 67;
         } else {
             $object->loadRefSejour();
             $sejour = $object->_ref_sejour;
             $doc_type = 7;
         }
         if ($sejour->sejour_id) {
             $sej_id = $sejour->sejour_id;
             $sejour->loadRefEtablissement();
             $etab_id = $sejour->_ref_group->_id;
             $etab_nom = $sejour->_ref_group->text;
         } else {
             $sej_id = -1;
             $object->_ref_praticien->loadRefFunction();
             $object->_ref_praticien->_ref_function->loadRefGroup();
             $etab_id = $object->_ref_praticien->_ref_function->_ref_group->_id;
             $etab_nom = $object->_ref_praticien->_ref_function->_ref_group->text;
         }
     }
     $praticien = $object->_ref_praticien;
     $aut_id = $praticien->_id;
     $aut_nom = $praticien->_user_last_name;
     $aut_prenom = $praticien->_user_first_name;
     $aut_numOrdre = $praticien->adeli ? $praticien->adeli : "";
     $patient = $object->_ref_patient;
     $pat_id = $patient->_id;
     $pat_civilite = CMedinetSender::$civiliteConversion[$patient->sexe];
     $pat_nomNaissance = $patient->nom_jeune_fille ? $patient->nom_jeune_fille : $patient->nom;
     $pat_nomUsuel = $patient->nom_jeune_fille ? $patient->nom : "";
     $pat_prenom = $patient->prenom;
     $pat_sexe = CMedinetSender::$sexeConversion[$patient->sexe];
     $pat_dateNaissance = $patient->naissance;
     $pat_cpNaissance = $patient->cp_naissance;
     $pat_villeNaissance = $patient->lieu_naissance ? $patient->lieu_naissance : "";
     $pat_cinseePaysNaissance = $patient->pays_naissance_insee ? $patient->pays_naissance_insee : -1;
     $pat_adresseVie = $patient->adresse;
     $pat_cpVie = $patient->cp;
     $pat_villeVie = $patient->ville;
     $pat_cinseePaysVie = $patient->pays_insee ? $patient->pays_insee : -1;
     $pat_telephone1 = $patient->tel;
     $pat_telephone2 = $patient->tel2;
     $act_id = $object->_id;
     $doc_id = $docItem->_id;
     $spec_cpam_id = $praticien->_ref_spec_cpam->spec_cpam_id;
     $act_pathologie = isset(CMedinetSender::$cpamConversion[$spec_cpam_id]) ? CMedinetSender::$cpamConversion[$spec_cpam_id] : 0;
     if ($docItem instanceof CCompteRendu) {
         $doc_nom = $docItem->nom;
         $doc_titre = $docItem->nom;
         $doc_nomReel = $docItem->nom;
         $doc_typeMime = "text/html";
         $log = new CUserLog();
         $log->type = "create";
         $log->object_id = $docItem->_id;
         $log->object_class = $docItem->_class;
         $log->loadMatchingObject();
         $act_dateCreationActe = CMbDT::date($log->date);
         $fichier = base64_encode($docItem->getBinaryContent());
     }
     if ($docItem instanceof CFile) {
         $doc_nom = $docItem->file_name;
         $doc_titre = $docItem->file_name;
         $doc_nomReel = $docItem->file_real_filename;
         $doc_typeMime = $docItem->file_type;
         $act_dateCreationActe = CMbDT::date($docItem->file_date);
         $fichier = base64_encode($docItem->getBinaryContent());
     }
     $doc_commentaire = "";
     $invalidation = 0;
     if ($messages = $this->checkParameters($object)) {
         CAppUI::setMsg($messages, UI_MSG_ERROR);
         return;
     }
     $parameters = array("sej_id" => $sej_id, "aut_id" => $aut_id, "aut_nom" => $aut_nom, "aut_prenom" => $aut_prenom, "aut_numOrdre" => $aut_numOrdre, "pat_id" => $pat_id, "pat_civilite" => $pat_civilite, "pat_nomNaissance" => $pat_nomNaissance, "pat_nomUsuel" => $pat_nomUsuel, "pat_prenom" => $pat_prenom, "pat_sexe" => $pat_sexe, "pat_dateNaissance" => $pat_dateNaissance, "pat_cpNaissance" => $pat_cpNaissance, "pat_villeNaissance" => $pat_villeNaissance, "pat_cinseePaysNaissance" => $pat_cinseePaysNaissance, "pat_adresseVie" => $pat_adresseVie, "pat_cpVie" => $pat_cpVie, "pat_villeVie" => $pat_villeVie, "pat_cinseePaysVie" => $pat_cinseePaysVie, "pat_telephone1" => $pat_telephone1, "pat_telephone2" => $pat_telephone2, "doc_id" => $doc_id, "doc_nom" => $doc_nom, "doc_titre" => $doc_titre, "doc_commentaire" => $doc_commentaire, "doc_type" => $doc_type, "doc_nomReel" => $doc_nomReel, "doc_typeMime" => $doc_typeMime, "act_id" => $act_id, "act_pathologie" => $act_pathologie, "act_dateActe" => $act_dateActe, "act_dateCreationActe" => $act_dateCreationActe, "act_dateValidationActe" => $act_dateValidationActe, "etab_id" => $etab_id, "etab_nom" => $etab_nom, "invalidation" => $invalidation, "fichier" => $fichier);
     $parameters = array_map("utf8_encode", $parameters);
     // Identifiant de la transaction
     if (null == ($transactionId = $this->clientSOAP->saveNewDocument_withStringFile($parameters))) {
         return;
     }
     $transactionId = $transactionId->saveNewDocument_withStringFileResult;
     $parameters = array("transactionId" => $transactionId);
     // Statut de la transaction
     if (null == ($status = $this->clientSOAP->getStatus($parameters))) {
         return;
     }
     $status = $status->getStatusResult;
     if (isset(CMedinetSender::$descriptifStatus[$status])) {
         CAppUI::setMsg(CMedinetSender::$descriptifStatus[$status]);
     } else {
         CAppUI::setMsg("Aucun statut n'a été transmis", UI_MSG_ALERT);
     }
     // Création de l'identifiant externe
     $idex = new CIdSante400();
     //Paramétrage de l'id 400
     $idex->object_class = $docItem->_class;
     $idex->tag = CMedinetSender::$tag;
     // Affectation de l'id400 a la transaction
     $idex->id400 = $transactionId;
     $idex->object_id = $docItem->_id;
     $idex->_id = null;
     $idex->last_update = CMbDT::dateTime();
     $idex->store();
     // Change l'etat du document
     $docItem->etat_envoi = "oui";
     return true;
 }
Пример #7
0
 /**
  * Counts the recent user logs
  *
  * @param string   $object_class The object class
  * @param ref[]    $ids          The list of IDs
  * @param datetime $recent       The date considered as recent
  *
  * @return int
  */
 static function countRecentFor($object_class, $ids, $recent)
 {
     if (!count($ids)) {
         return 0;
     }
     $log = new CUserLog();
     $where = array();
     $where["object_class"] = "= '{$object_class}'";
     $where["date"] = "> '{$recent}'";
     $where["object_id"] = CSQLDataSource::prepareIn($ids);
     return $log->countList($where);
 }
Пример #8
0
            $where["object_id"] = "= '{$filter->object_id}'";
        }
        if ($filter->object_class) {
            $where["object_class"] = "= '{$filter->object_class}'";
        }
}
if ($filter->type) {
    $where["type"] = "= '{$filter->type}'";
}
if ($filter->_date_min) {
    $where[] = "date >= '{$filter->_date_min}'";
}
if ($filter->_date_max) {
    $where[] = "date <= '{$filter->_date_max}'";
}
$log = new CUserLog();
$list = null;
$list_count = null;
$is_admin = CCanDo::admin();
$dossiers_medicaux_shared = CAppUI::conf("dPetablissement dossiers_medicaux_shared");
if (!$stats) {
    $index = isset($where["object_id"]) ? "object_id" : null;
    /** @var CUserLog[] $list */
    $list = $log->loadList($where, "date DESC", "{$start}, 100", null, null, $index);
    // Sort by id with PHP cuz dumbass MySQL won't limit rowscan before sorting
    // even though `date` is explicit as first intention sorter AND obvious index in most cases
    // Tends to be a known limitation
    array_multisort(CMbArray::pluck($list, "_id"), SORT_DESC, $list);
    $list_count = $log->countList($where, null, null, $index);
    $group_id = CGroups::loadCurrent()->_id;
    $users = CStoredObject::massLoadFwdRef($list, "user_id");
Пример #9
0
 * @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();
$user_id = CValue::get("user_id");
$object_class = CValue::get("object_class");
$id_min = CValue::get("id_min");
$id_max = CValue::get("id_max");
$date_min = CValue::get("_date_min");
$date_max = CValue::get("_date_max");
$step = CValue::get("step");
$simulate = CValue::get("simulate");
$user_log = new CUserLog();
$where = array();
$where["object_class"] = "= '{$object_class}'";
$where["date"] = "BETWEEN '{$date_min}' AND '{$date_max}'";
$where['type'] = "= 'create'";
$where["object_id"] = "BETWEEN '{$id_min}' AND '{$id_max}'";
if ($user_id) {
    $where["user_id"] = "= '{$user_id}'";
}
// Mode simulation (on compte les objets correspondants
if ($simulate) {
    $nb_objects = $user_log->countList($where);
    CAppUI::stepAjax("Il y a {$nb_objects} qui correspondent à la recherche");
    CApp::rip();
}
// Purge réelle
Пример #10
0
 /**
  * @see parent::loadLogs()
  */
 function loadLogs()
 {
     $this->setExClass();
     $ds = $this->_spec->ds;
     $where = array("object_class" => $ds->prepare("=%", $this->_class), "object_id" => $ds->prepare("=%", $this->_id));
     $log = new CUserLog();
     $this->_ref_logs = $log->loadList($where, "user_log_id DESC", 100, null, null, "object_id");
     // loadRefsFwd will fail because the ExObject's class doesn't really exist
     foreach ($this->_ref_logs as &$_log) {
         $_log->loadRefUser();
     }
     // the first is at the end because of the date order !
     $this->_ref_first_log = end($this->_ref_logs);
     $this->_ref_last_log = reset($this->_ref_logs);
 }
Пример #11
0
    $urgence->_alternate_plages = $plage->loadList($where, $order);
    foreach ($urgence->_alternate_plages as $curr_plage) {
        $curr_plage->loadRefsFwd();
    }
}
$anesth = new CMediusers();
$anesths = $anesth->loadAnesthesistes(PERM_READ);
$date_last_checklist = array();
foreach ($listSalles as $salle) {
    if ($salle->cheklist_man) {
        $checklist = new CDailyCheckList();
        $checklist->object_class = $salle->_class;
        $checklist->object_id = $salle->_id;
        $checklist->loadMatchingObject("date DESC");
        if ($checklist->_id) {
            $log = new CUserLog();
            $log->object_id = $checklist->_id;
            $log->object_class = $checklist->_class;
            $log->loadMatchingObject("date DESC");
            $date_last_checklist[$salle->_id] = $log->date;
        } elseif ($checklist->date) {
            $date_last_checklist[$salle->_id] = $checklist->date;
        } else {
            $date_last_checklist[$salle->_id] = "";
        }
    }
}
// Création du template
$smarty = new CSmartyDP();
$smarty->debugging = false;
$smarty->assign("urgences", $urgences);
CCanDo::checkAdmin();
$query = <<<SQL
SELECT user_log_id, object_id
FROM user_log
LEFT JOIN sejour ON sejour.sejour_id = user_log.object_id
WHERE
  sejour.mode_entree != '7' AND
  user_log.object_class = 'CSejour' AND
  user_log.extra     LIKE '%"entree_reelle":""%' AND
  user_log.extra     LIKE '%"etablissement_entree_id":%'AND
  user_log.extra NOT LIKE '%"etablissement_entree_id":""%'
  LIMIT 50
SQL;
$ds = CSQLDataSource::get("std");
$logs = $ds->loadList($query);
foreach ($logs as $_log) {
    $user_log = new CUserLog();
    $user_log->load($_log["user_log_id"]);
    $values = $user_log->getOldValues();
    /** @var CSejour $sejour */
    $sejour = $user_log->loadTargetObject();
    $sejour->etablissement_entree_id = $values["etablissement_entree_id"];
    $sejour->mode_entree = "7";
    // transfert
    if ($msg = $sejour->store()) {
        CAppUI::setMsg($msg, UI_MSG_WARNING);
    } else {
        CAppUI::setMsg("Etablissement d'entrée rétabli", UI_MSG_OK);
    }
}
echo CAppUI::getMsg();
/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage System
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkAdmin();
$user_id = CValue::get("user_id");
$date = CValue::get("date");
$object_class = CValue::get("object_class");
$fields = CValue::get("fields");
$user_log = new CUserLog();
$where = array("object_class" => "= '{$object_class}'");
if ($user_id) {
    $where["user_id"] = " = '{$user_id}'";
}
if ($date) {
    $where["date"] = ">= '{$date}'";
}
$where["type"] = "= 'store'";
if ($fields) {
    $whereField = array();
    foreach ($fields as $_field) {
        $whereField[] = "\r\n      fields LIKE '{$_field} %' OR \r\n      fields LIKE '% {$_field} %' OR \r\n      fields LIKE '% {$_field}' OR \r\n      fields LIKE '{$_field}'";
    }
    $where[] = implode(" OR ", $whereField);
}
Пример #14
0
<?php

/**
 * $Id: httpreq_vw_object_history.php 27870 2015-04-07 07:51:11Z mytto $
 *
 * @package    Mediboard
 * @subpackage System
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 27870 $
 */
CCanDo::check();
$object = mbGetObjectFromGet("object_class", "object_id", "object_guid");
CView::enforceSlave();
$log = new CUserLog();
$log->setObject($object);
$count = $log->countMatchingList();
/** @var CUserLog[] $logs */
$logs = $log->loadMatchingList("date DESC", 10);
foreach ($logs as $key => $_log) {
    $_log->setObject($object);
    $_log->loadRefUser();
    $_log->getOldValues();
}
$more = $count - count($logs);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("logs", $logs);
$smarty->assign("more", $more);
$smarty->display("vw_object_history.tpl");
Пример #15
0
 * @subpackage System
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkAdmin();
// FIXME la restauration n'est pas totale car seulement le premier user_log de l'objet (date ASC) est utilisé
$user_id = CValue::post("user_id");
$date = CValue::post("date");
$object_class = CValue::post("object_class");
$fields = CValue::post("fields");
$do_it = CValue::post("do_it");
CValue::setSession("user_id", $user_id);
CValue::setSession("object_class", $object_class);
CValue::setSession("date", $date);
$user_log = new CUserLog();
$where = array("object_class" => "= '{$object_class}'");
if ($user_id) {
    $where["user_id"] = " = '{$user_id}'";
}
if ($date) {
    $where["date"] = ">= '{$date}'";
}
$where["type"] = "= 'store'";
if ($fields) {
    $whereField = array();
    foreach ($fields as $_field) {
        $whereField[] = "\r\n      fields LIKE '{$_field} %' OR \r\n      fields LIKE '% {$_field} %' OR \r\n      fields LIKE '% {$_field}' OR \r\n      fields LIKE '{$_field}'";
    }
    $where[] = implode(" OR ", $whereField);
}
Пример #16
0
 * Create user authentication entry
 *
 * @param CSQLDataSource $ds   Data source
 * @param array          $data Data
 *
 * @return string The SQL query
 */
$create_user_auth = function (CSQLDataSource $ds, $data) {
    $query = "INSERT INTO user_authentication\n              (user_id, auth_method, datetime_login, id_address)\n              VALUES (?1, ?2, ?3, ?4);";
    return $ds->prepare($query, $data["user_id"], 'basic', $data["date"], $data["ip_address"] ? inet_ntop($data["ip_address"]) : '');
};
$inserts = array(array("CUser", "store", "user_last_login", $create_user_auth), array("CUser", "store", "user_password user_last_login", $create_user_auth), array("CUser", "store", "user_password user_salt user_last_login", $create_user_auth));
// Triplets defining user log entries to be removed
$removers = array(array("CSourceFTP", "store", "counter"), array("CPrisePosologie", "store", "last_generation"), array("CPrescriptionLineElement", "store", "last_generation"), array("CTriggerMark", "create", ""), array("CTriggerMark", "store", "mark"), array("CTriggerMark", "store", "mark done"), array("CMovement", "create", ""), array("CMovement", "store", "last_update"), array("CMovement", "store", "affectation_id"), array("CMovement", "store", "affectation_id last_update"), array("CMovement", "store", "movement_type last_update"), array("CMovement", "store", "start_of_movement last_update"), array("CMovement", "delete", ""), array("CAlert", "create", ""), array("CAlert", "store", "comments"), array("CAlert", "store", "handled handled_date handled_user_id"), array("CAlert", "delete", ""), array("", "", ""));
$counts = array("delete" => 0, "copy" => 0, "insert" => 0);
$log = new CUserLog();
$ds = $log->getDS();
// Primary key clauses
$min = $offset;
$max = $offset + $step - 1;
//<editor-fold desc=" ----- Remove ----- ">
$request = new CRequest();
$request->addWhereClause("user_log_id", "BETWEEN {$min} AND {$max}");
$request->addForceIndex("PRIMARY");
// Removers clauses
$triplets = array();
foreach ($removers as $_remover) {
    list($object_class, $type, $fields) = $_remover;
    $triplets[] = "{$object_class}-{$type}" . ($fields ? "-{$fields}" : "");
}
$where = "CONCAT_WS('-', `object_class`, `type`, `fields`) " . CSQLDataSource::prepareIn($triplets);
Пример #17
0
 * @link     http://www.mediboard.org
 */
if (!CAppUI::pref("allowed_modify_identity_status")) {
    CAppUI::redirect("m=system&a=access_denied");
}
$date = CValue::get('date');
$ids = CValue::get('ids');
if (!$ids || !$date) {
    CAppUI::stepAjax('common-error-Missing parameter', UI_MSG_ERROR);
}
$patient_ids = explode('-', $ids);
$date = preg_replace('/(\\d\\d)\\/(\\d\\d)\\/(\\d\\d\\d\\d)/', '\\3-\\2-\\1', $date);
if (!$patient_ids || !$date) {
    CAppUI::stepAjax('common-error-Invalid parameter', UI_MSG_ERROR);
}
$user_log = new CUserLog();
$ds = $user_log->getDS();
$where = array('object_class' => "= 'CPatient'", 'object_id' => $ds->prepareIn($patient_ids), 'type' => "= 'merge'", 'date' => $ds->prepare("BETWEEN ?1 AND ?2", "{$date} 00:00:00", "{$date} 23:59:59"));
$logs = $user_log->loadList($where);
foreach ($logs as $_log) {
    $_log->loadView();
    /** @var CPatient $patient */
    $patient = $_log->_ref_object;
    $identifiants = $patient->loadBackRefs('identifiants');
    /** @var CIdSante400 $_id */
    foreach ($identifiants as $_id) {
        $_id->getSpecialType();
    }
}
$smarty = new CSmartyDP();
$smarty->assign('date', $date);