/**
  * Connect to a AS400 DB2 SQL server via ODBC driver
  * 
  * @throws Error on misconfigured or anavailable server
  * 
  * @return void
  */
 static function connect()
 {
     if (self::$dbh) {
         return;
     }
     $config = CAppUI::conf("sante400");
     if (null == ($dsn = $config["dsn"])) {
         trigger_error("Data Source Name not defined, please configure module", E_USER_ERROR);
         CApp::rip();
     }
     // Fake data source for chrono purposes
     CSQLDataSource::$dataSources[$dsn] = new CMySQLDataSource();
     $ds =& CSQLDataSource::$dataSources[$dsn];
     $ds->dsn = $dsn;
     self::$chrono =& CSQLDataSource::$dataSources[$dsn]->chrono;
     self::$chrono->start();
     $prefix = $config["prefix"];
     try {
         self::$dbh = new PDO("{$prefix}:{$dsn}", $config["user"], $config["pass"]);
         self::$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } catch (PDOException $e) {
         mbTrace("cauguht failure on first datasource");
         if (null == ($dsn = $config["other_dsn"])) {
             throw $e;
         }
         self::$dbh = new PDO("{$prefix}:{$dsn}", $config["user"], $config["pass"]);
         self::$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     }
     self::$chrono->stop("connection");
     self::traceChrono("connection");
 }
 /**
  * Build LCH segement
  *
  * @param CHL7v2Event $event Event
  *
  * @return null
  */
 function build(CHL7v2Event $event)
 {
     parent::build($event);
     $entity = $this->entity;
     $code = $this->code;
     $primary_key = array_search(get_class($entity), CHL7v2EventMFN::$entities);
     $primary_key = $primary_key . $entity->_id;
     mbTrace($entity);
     // LCH-1: Primary Key Value -LCH - LCH (PL) (Requis)
     $data[] = $primary_key;
     // LCH-2: Segment Action Code - LCH (ID) (Optional)
     $data[] = null;
     // LCH-3: Segment Unique Key - LCH (EI) (Optional)
     $data[] = null;
     // LCH-4: Location Characteristic ID - LCH (CWE) (Requis)
     $HL7_value = CHL7v2TableEntry::mapTo("7878", $code);
     $data[] = array(array($HL7_value, CHL7v2TableEntry::getDescription("7878", $HL7_value), "L"));
     // if si dans la chaine tu as RSPNSBL
     // alors :
     // $user = $entity->loadRefUser();
     // $user->$code
     // else
     // $entity->$code
     // LCH-5: Location Characteristic Value - LCH (CWE) (Requis)
     $data[] = null;
     $this->fill($data);
 }
 /**
  * Test Q22 - Find Candidates
  *
  * @param CCnStep $step Step
  *
  * @throws CMbException
  *
  * @return void
  */
 static function testQ22(CCnStep $step)
 {
     $profil = "PDQ";
     $transaction = "ITI21";
     $message = "QBP";
     $code = "Q22";
     mbTrace($step);
     // PDQ_Multiple_Query
     switch ($step->number) {
         case '20':
             // PID.5.1.1 = MOO*
             break;
         default:
     }
 }
 /**
  * @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);
     }
 }
 /**
  * Log shortcut to mbTrace
  *
  * @param string $label Add an optional label
  * @param bool   $log   Log to file or echo data
  *
  * @return int The size of the data written in the log file
  **/
 function log($label = null, $log = true)
 {
     return mbTrace($this->getPlainFields(), $label, $log);
 }
                case "MLLP":
                    $server_class = "CMLLPServer";
                    break;
                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);
 * @version $Revision:$
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 */
CCanDo::checkAdmin();
$action = CValue::post("action", "modify");
$sejour = new CSejour();
switch ($action) {
    case "modify":
        while (!$sejour->load(rand(1, 5000))) {
        }
        // randomize libelle
        $sejour->libelle = $sejour->libelle ? $sejour->libelle : "un libelle pour le mettre dans l'ordre";
        $libelle = str_split($sejour->libelle);
        shuffle($libelle);
        $sejour->libelle = implode("", $libelle);
        break;
    case "create":
        //$sejour->sample();
        $sejour->group_id = 1;
        $sejour->praticien_id = 73;
        $sejour->patient_id = rand(1, 5000);
        $sejour->entree_prevue = CMbDT::dateTime();
        $sejour->sortie_prevue = CMbDT::dateTime("+1 day");
        //$patient->updateFormFields();
        break;
}
CAppUI::displayMsg($sejour->store(), "CSejour-msg-{$action}");
mbTrace($sejour);
echo CAppUI::getMsg();
CApp::rip();
Exemple #8
0
    if ($sejour_intervention && !$intervention_ok) {
        $msg_error = "<strong>Impossible de sauvegarder l'intervention :</strong> " . $msg_error;
        // Création du template
        $smarty = new CSmartyDP();
        $smarty->assign("praticien_id", $praticien_id);
        $smarty->assign("patient", $patient);
        $smarty->assign("sejour", $sejour);
        $smarty->assign("intervention", $intervention);
        $smarty->assign("sejour_intervention", $sejour_intervention);
        $smarty->assign("msg_error", $msg_error);
        $smarty->display("dhe_externe.tpl");
        return;
    }
}
if ($patient_ok && !$sejour->libelle) {
    CAppUI::redirect("m=dPplanningOp&a=vw_edit_planning&chir_id={$praticien_id}&operation_id=0&pat_id=" . $patient->_id);
} elseif ($patient_ok && $sejour_ok && !$sejour_intervention) {
    CAppUI::redirect("m=dPplanningOp&tab=vw_edit_sejour&sejour_id=" . $sejour->_id);
} elseif ($patient_ok && $sejour_ok && $intervention_ok && $intervention->plageop_id) {
    CAppUI::redirect("m=dPplanningOp&tab=vw_edit_planning&operation_id=" . $intervention->_id);
} elseif ($patient_ok && $sejour_ok && $intervention_ok && !$intervention->plageop_id) {
    CAppUI::redirect("m=dPplanningOp&tab=vw_edit_urgence&operation_id=" . $intervention->_id);
} else {
    mbTrace("erreur indéfinie");
    $msg_error = "Erreur indéfinie";
    // Création du template
    $smarty = new CSmartyDP();
    $smarty->assign("praticien_id", $praticien_id);
    $smarty->assign("msg_error", $msg_error);
    $smarty->display("dhe_externe.tpl");
}
 /**
  * Trace value with given title
  * 
  * @param mixed  $value Value to trace
  * @param string $title Optional title
  *
  * @return void
  */
 function trace($value, $title = null)
 {
     if (self::$verbose) {
         mbTrace($value, $title);
     }
 }
 /**
  * Edition des journaux selon le type
  *
  * @param bool $read           lecture
  * @param bool $create_journal Création du journal
  *
  * @return void
  */
 function editJournal($read = true, $create_journal = true)
 {
     if ($create_journal) {
         $journal = new CJournalBill();
         $journal->type = $this->type_pdf;
         $journal->nom = "Journal_" . $this->type_pdf . "_" . CMbDT::date();
         $journal->_factures = $this->factures;
         if ($msg = $journal->store()) {
             mbTrace($msg);
         } else {
             $this->journal_id = $journal->_id;
         }
     }
     // Creation du PDF
     $this->pdf = new CMbPdf('l', 'mm');
     $this->pdf->setPrintHeader(false);
     $this->pdf->setPrintFooter(false);
     $this->font = "vera";
     $this->fontb = $this->font . "b";
     $this->pdf->setFont($this->font, '', 8);
     $this->page = 0;
     $this->editEntete();
     switch ($this->type_pdf) {
         case "paiement":
             $this->editPaiements();
             break;
         case "debiteur":
             $this->editDebiteur();
             break;
         case "rappel":
             $this->editRappel();
             break;
         case "checklist":
             $this->editCheckList();
             break;
     }
     if ($create_journal) {
         $file = new CFile();
         $file->file_name = $journal->nom . ".pdf";
         $file->file_type = "application/pdf";
         $file->author_id = CMediusers::get()->_id;
         $file->file_category_id = 1;
         $file->setObject($journal);
         $file->fillFields();
         $file->putContent($this->pdf->Output('Factures.pdf', "S"));
         if ($msg = $file->store()) {
             echo $msg;
         }
         if ($this->type_pdf == "checklist") {
             $user = CMediusers::get();
             $printer = new CPrinter();
             $printer->function_id = $user->function_id;
             $printer->label = "justif";
             $printer->loadMatchingObject();
             if (!$printer->_id) {
                 CAppUI::setMsg("Les imprimantes ne sont pas paramétrées", UI_MSG_ERROR);
                 echo CAppUI::getMsg();
                 return false;
             }
             $file = new CFile();
             $pdf = $this->pdf->Output('Factures.pdf', "S");
             $file_path = tempnam("tmp", "facture");
             $file->_file_path = $file_path;
             file_put_contents($file_path, $pdf);
             $printer->loadRefSource()->sendDocument($file);
             unlink($file_path);
         }
     }
     if ($read) {
         //Affichage du fichier pdf
         $this->pdf->Output('Factures.pdf', "I");
     }
 }
// Filtre sur les fonctions
if ($filterFunction) {
    $leftjoin["users_mediboard"] = "sejour.praticien_id = users_mediboard.user_id";
    $where["users_mediboard.function_id"] = " = '{$filterFunction}'";
}
$sejour = new CSejour();
$alerte = $sejour->countList($where, null, $leftjoin);
CApp::$chrono->stop("Patient à placer dans la semaine");
CApp::$chrono->start();
$affectation = new CAffectation();
$affectation->entree = CMbDT::addDateTime("08:00:00", $date);
$affectation->sortie = CMbDT::addDateTime("23:00:00", $date);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("services_ids", $services_ids);
$smarty->assign("affectation", $affectation);
$smarty->assign("date", $date);
$smarty->assign("demain", CMbDT::date("+ 1 day", $date));
$smarty->assign("heureLimit", $heureLimit);
$smarty->assign("mode", $mode);
$smarty->assign("emptySejour", $emptySejour);
$smarty->assign("filterFunction", $filterFunction);
$smarty->assign("totalLits", $totalLits);
$smarty->assign("services", $services);
$smarty->assign("alerte", $alerte);
$smarty->assign("prestations", CPrestation::loadCurrentList());
$smarty->assign("prestation_id", $prestation_id);
$smarty->display("inc_tableau_affectations_lits.tpl");
if (CAppUI::pref("INFOSYSTEM")) {
    mbTrace(CMbArray::pluck(CApp::$chrono->report, "total"), "Rapport uniquement visible avec les informations système");
}
Exemple #12
0
 /**
  * @see parent::store()
  */
 function store()
 {
     $this->updatePlainFields();
     $this->completeField("chir_id", "spec_id");
     $old = new CPlageOp();
     if ($this->_id) {
         $old->load($this->_id);
         $old->loadRefsOperations();
     }
     // Pas de changement de date si on a déjà des interventions
     if ($this->fieldModified("date") && count($old->_ref_operations)) {
         return CAppUI::tr("CPlageOp-failed-change_date", count($old->_ref_operations));
     }
     // Erreur si on est en multi-praticiens, qu'il y a des interventions et qu'on veut mettre un praticien
     if ($this->fieldValued("chir_id") && !$this->unique_chir && $old->spec_id && count($old->_ref_operations)) {
         mbTrace("all the same to me");
     }
     if (null !== $this->chir_id && $this->_id && !$this->unique_chir) {
         if (count($old->_ref_operations) && $old->spec_id && $this->chir_id) {
             return CAppUI::tr("CPlageOp-failed-multi_chir", count($old->_ref_operations));
         }
     }
     // Si on change de praticien alors qu'il y a déjà des interventions
     if ($this->fieldAltered("chir_id") && count($old->_ref_operations)) {
         // Si certaines ne sont pas annulées, on sort
         if ($this->countOperationsAnnulees() != count($old->_ref_operations)) {
             return CAppUI::tr("CPlageOp-failed-change_chir", count($old->_ref_operations));
         }
         // Si toutes les interventions sont annulées, on les met hors plage
         $this->completeField("salle_id", "date");
         foreach ($old->_ref_operations as $_op) {
             $_op->plageop_id = "";
             $_op->date = $this->date;
             $_op->salle_id = $this->salle_id;
             $_op->store();
         }
     }
     // Erreur si on créé-modifie une plage sur une salle bloquée
     $salle = $this->loadRefSalle();
     if (count($salle->loadRefsBlocages($this->date))) {
         return CAppUI::tr("CPlageOp-failed-use_locked_room", $salle->_view);
     }
     // Modification du salle_id de la plage -> repercussion sur les interventions
     if ($this->fieldModified("salle_id")) {
         foreach ($old->_ref_operations as $_operation) {
             if ($_operation->salle_id == $old->salle_id) {
                 $_operation->salle_id = $this->salle_id;
                 $_operation->store(false);
             }
         }
     }
     // Modification du début de la plage ou des minutes entre les interventions
     $this->completeField("debut", "temps_inter_op");
     if ($this->fieldModified("debut") || $this->fieldModified("temps_inter_op")) {
         if ($this->fieldModified("temps_inter_op")) {
             $with_cancelled = CAppUI::conf("dPplanningOp COperation save_rank_annulee_validee");
             $this->loadRefsOperations($with_cancelled, "rank, rank_voulu, horaire_voulu", true);
         }
         $this->reorderOp();
     }
     if (!$this->_id || !$this->original_owner_id && !$this->original_function_id) {
         $this->original_owner_id = $this->chir_id;
         $this->original_function_id = $this->spec_id;
     }
     return parent::store();
 }
<?php

/**
 * $Id: do_fichePaie_save.php 19621 2013-06-20 20:40:45Z phenxdesign $
 *
 * @package    Mediboard
 * @subpackage GestionCab
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 19621 $
 */
mbTrace("Start");
$do = new CDoObjectAddEdit("CFichePaie");
$do->redirect = null;
$do->doIt();
mbTrace("End");
$fichePaie = new CFichePaie();
$fichePaie->load($do->_obj->_id);
$fichePaie->loadRefsFwd();
$fichePaie->_ref_params_paie->loadRefsFwd();
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("fichePaie", $fichePaie);
$fichePaie->final_file = $smarty->fetch("print_fiche.tpl");
mbTrace($fichePaie->store());
CApp::rip();
Exemple #14
0
$where = array();
CApp::setTimeLimit(300);
$loops = CValue::get("loops", 100);
$trunk = CValue::get("trunk", 100);
mbTrace($loops, "loops");
mbTrace($trunk, "trunk");
$problems = array();
for ($loop = 0; $loop < $loops; $loop++) {
    $starting = $loop * $trunk;
    $ds = $doc->_spec->ds;
    $query = "SELECT `compte_rendu`.`compte_rendu_id`, `contenthtml`.`content` \r\n    FROM compte_rendu, contenthtml\r\n    WHERE compte_rendu.content_id = contenthtml.content_id\r\n    ORDER BY compte_rendu_id DESC\r\n    LIMIT {$starting}, {$trunk}";
    $docs = $ds->loadHashList($query);
    foreach ($docs as $doc_id => $doc_source) {
        // Root node surrounding
        $source = utf8_encode("<div>{$doc_source}</div>");
        // Entity purge
        $source = preg_replace("/&\\w+;/i", "", $source);
        // Escape warnings, returns false if really invalid
        $doc = new CMbXMLDocument();
        if (false == ($validation = $doc->loadXML($source))) {
            $doc = new CCompteRendu();
            $doc->load($doc_id);
            $problems[$doc_id] = $doc;
        }
    }
}
mbTrace(count($problems), "Problems count");
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("problems", $problems);
$smarty->display("check_document.tpl");
 function fetchAssoc($result, $read_lob = true)
 {
     if (CSQLDataSource::$trace) {
         $t = microtime(true);
     }
     $assoc = oci_fetch_assoc($result);
     if (CSQLDataSource::$trace) {
         $new_t = microtime(true);
         mbTrace(@$this->_queries[$result], "FETCH ASSOC in " . ($new_t - $t) * 1000 . " ms");
         $t = $new_t;
     }
     if ($read_lob) {
         $assoc = $this->readLOB($assoc);
         if (CSQLDataSource::$trace) {
             $new_t = microtime(true);
             mbTrace(@$this->_queries[$result], "READ LOB in " . ($new_t - $t) * 1000 . " ms");
             $t = $new_t;
         }
     }
     return $assoc;
 }
Exemple #16
0
<?php

/**
 * $Id$
 *  
 * @category Bloc
 * @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::checkEdit();
$miner = new CDailySalleOccupation();
mbTrace($miner->countUnmined(), "unmined");
mbTrace($miner->countUnremined(), "un-remined");
mbTrace($miner->countUnpostmined(), "un-postmined");
$smarty = new CSmartyDP();
$smarty->display("inc_mine_salle.tpl");
Exemple #17
0
$msg = new CHL7v2Message();
$msg->version = "2.5";
$msg->name = "ADT_A08";
//$msg->fieldSeparator = "a";
//$msg->componentSeparator = "b";
//$msg->subcomponentSeparator = "e";
//$msg->repetitionSeparator = "c";
//$msg->escapeCharacter = "d";
$segment = CHL7v2Segment::create("MSH", $msg);
$data = array(null, null, "Mediboard", "Mediboard_finess", "no_receiver", null, CMbDT::dateTime(), null, null, "Msg ctrl id", "A", null, 15, null, null, null, null, "8859/1", null, null, null);
$segment->fill($data);
$msg->appendChild($segment);
$segment = CHL7v2Segment::create("PID", $msg);
$data = array(0 => 1, 1 => null, 2 => array(0 => array(0 => '323241', 1 => null, 2 => null, 3 => array(0 => 'Mediboard', 1 => '1.2.250.1.2.3.4', 2 => 'OpenXtrem'), 4 => 'RI'), 1 => array(0 => 'fgfg', 1 => null, 2 => null, 3 => array(0 => null, 1 => '1.2.250.1.213.1.4.2', 2 => 'ISO'), 4 => 'INS-C', 5 => null, 6 => '1946-10-17')), 3 => null, 4 => array(0 => array(0 => 'EZZHJ', 1 => 'Rtaso', 2 => 'qldax', 3 => null, 4 => 'dr', 5 => null, 6 => 'D', 7 => 'A'), 1 => array(0 => 'MEBJO', 1 => 'Rtaso', 2 => 'qldax', 3 => null, 4 => 'dr', 5 => null, 6 => 'L', 7 => 'A')), 5 => null, 6 => '1987-09-24', 7 => 'F', 8 => null, 9 => null, 10 => array(0 => array(0 => "adresse test \r\n \\ | & ^ ~", 1 => null, 2 => 'rtckkljfgrw', 3 => null, 4 => '4294967295', 5 => null, 6 => 'H'), 1 => array(0 => null, 1 => null, 2 => 'vlfxif', 3 => null, 4 => '40048', 5 => '000', 6 => 'BR')), 11 => null, 12 => array(0 => array(0 => '43502', 1 => 'PRN', 2 => 'PH'), 1 => array(0 => '42287', 1 => 'ORN', 2 => 'CP'), 2 => array(0 => 'oezym', 1 => 'ORN', 2 => 'PH')), 13 => null, 14 => null, 15 => null, 16 => null, 17 => null, 18 => null, 19 => null, 20 => null, 21 => null, 22 => null, 23 => null, 24 => null, 25 => null, 26 => null, 27 => null, 28 => '1905-05-06', 29 => 'Y');
$segment->fill($data);
$msg->appendChild($segment);
$msg->validate();
foreach ($msg->errors as $error) {
    mbTrace(@$error->entity->getPathString(), CAppUI::tr("CHL7v2Exception-" . $error->code) . " - " . $error->data);
}
echo "Généré";
echo $msg->flatten(true);
$message_str = $msg->flatten();
echo "Parsé";
$msg2 = new CHL7v2Message();
$msg2->parse($message_str);
$msg2->validate();
foreach ($msg2->errors as $error) {
    mbTrace(@$error->entity->getPathString(), CAppUI::tr("CHL7v2Exception-" . $error->code) . " - " . $error->data);
}
echo $msg2->flatten(true);
CCanDo::checkAdmin();
$action = CValue::get("action");
$source_ldap_id = CValue::get("source_ldap_id");
$ldaprdn = CValue::get("ldaprdn");
$ldappass = CValue::get("ldappass");
$filter = CValue::get("filter", "(samaccountname=*)");
$attributes = CValue::get("attributes");
$source_ldap = new CSourceLDAP();
$source_ldap->load($source_ldap_id);
try {
    $ldapconn = $source_ldap->ldap_connect();
    CAppUI::stepAjax("CSourceLDAP_connect", UI_MSG_OK, $source_ldap->host);
    $source_ldap->ldap_bind($ldapconn, $ldaprdn, $ldappass, true);
    $user = $ldaprdn ? $ldaprdn : "anonymous";
    $user = $source_ldap->bind_rdn_suffix ? $ldaprdn . $source_ldap->bind_rdn_suffix : $user;
    CAppUI::stepAjax("CSourceLDAP_authenticate", UI_MSG_OK, $source_ldap->host, $user);
} catch (CMbException $e) {
    $e->stepAjax(UI_MSG_ERROR);
}
if ($action == "search") {
    if ($attributes) {
        $attributes = preg_split("/\\s*[,\n\\|]\\s*/", $attributes);
    }
    try {
        $results = $source_ldap->ldap_search($ldapconn, $filter, $attributes ? $attributes : array());
    } catch (CMbException $e) {
        $e->stepAjax(UI_MSG_ERROR);
    }
    CAppUI::stepAjax("CSourceLDAP_search-results", UI_MSG_OK, $filter);
    mbTrace($results);
}
/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage PlanningOp
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkAdmin();
$operation = new COperation();
// Nombre d'interventions...
$counts["total"] = $operation->countList();
// Dans une plage...
$where["operations.plageop_id"] = "IS NOT NULL";
$counts["plaged"] = $operation->countList($where);
// Sans date!
$where["operations.date"] = "IS NULL";
$counts["missing"] = $operation->countList($where);
// Avec une date erronée!
$ljoin["plagesop"] = "plagesop.plageop_id = operations.plageop_id";
$where["operations.date"] = "IS NOT NULL";
$where[] = "plagesop.date != operations.date";
$counts["wrong"] = $operation->countList($where, null, $ljoin);
foreach ($operation->loadList($where, null, null, null, $ljoin) as $_operation) {
    mbTrace($_operation->_guid, $_operation->plageop_id);
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("counts", $counts);
$smarty->display("check_date_intervention.tpl");
<?php

/**
 * Edit transformaiton rule EAI
 *
 * @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();
$standard_name = CValue::get("standard_name");
$select_type = CValue::get("select_type");
mbTrace($standard_name);
 /**
  * Stop, trace latest step and restart a chronometer
  */
 function report()
 {
     foreach ($this->report as $msg => $_chrono) {
         mbTrace(number_format($_chrono->total * 1000, 2), "[Chrono] {$_chrono->nbSteps} '{$msg}' actions (ms)");
         if ($_chrono->nbSteps > 1) {
             mbTrace(number_format($_chrono->avgStep * 1000, 2), "[Chrono] action '{$msg}' average (ms)");
         }
     }
 }
Exemple #22
0
            }
        }
    }
}
if ($style) {
    addFiles("style", $zipFile, $typeArch);
}
if ($image) {
    addFiles("images", $zipFile, $typeArch);
}
if ($lib) {
    addFiles("lib/dojo", $zipFile, $typeArch);
    addFiles("lib/datepicker", $zipFile, $typeArch);
    addFiles("lib/scriptaculous", $zipFile, $typeArch);
}
if ($javascript) {
    addFiles("includes/javascript", $zipFile, $typeArch);
    addFiles("modules/dPrepas/javascript", $zipFile, $typeArch);
}
if ($typeArch == "tar") {
    mbTrace($zipFile->listContent(), "Contenu de l'archive");
} else {
    for ($i = 0; $i < $zipFile->numFiles; $i++) {
        $stat = $zipFile->statIndex($i);
        mbTrace(basename($stat['name']));
    }
}
if ($typeArch == "zip") {
    $zipFile->close();
}
CApp::rip();
<?php

/**
 * Dispatch event
 *
 * @category Webservices
 * @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();
$sender_soap_id = CValue::get("sender_soap_id");
$message = CValue::get("message");
$message = utf8_encode(stripcslashes($message));
$soap_handler = new CEAISoapHandler();
// Dispatch EAI
if (!($ack = $soap_handler->event($message, $sender_soap_id))) {
    CAppUI::stepAjax("Le fichier n'a pu être dispatché correctement", UI_MSG_ERROR);
    mbTrace($ack);
}
 /**
  * Lecture du fichier XML associé au rejet
  *
  * @param string $content_file contenu du fichier
  * @param bool   $details      enregistrement des informations
  *
  * @return null
  */
 function readXML($content_file = null, $details = false)
 {
     if (!$content_file) {
         $file = $this->loadRefFile();
         $file->updateFormFields();
         $content_file = file_get_contents($file->_file_path);
     }
     $doc = new CMbXMLDocument("UTF-8");
     $doc->loadXMLSafe($content_file);
     $xpath = new CMbXPath($doc);
     $xpath->registerNamespace("invoice", "http://www.forum-datenaustausch.ch/invoice");
     $payload = $xpath->queryUniqueNode("//invoice:payload");
     $timestamp = $xpath->getValueAttributNode($payload, "response_timestamp");
     $this->date = strftime('%Y-%m-%d', $timestamp);
     $invoice = $xpath->queryUniqueNode("//invoice:invoice");
     $this->num_facture = $xpath->getValueAttributNode($invoice, "request_id");
     $this->_date_facture = $xpath->getValueAttributNode($invoice, "request_date");
     $insurance = $xpath->queryUniqueNode("//invoice:insurance");
     $ean_party = $xpath->getValueAttributNode($insurance, "ean_party");
     $corr = new CCorrespondantPatient();
     $corr->ean = $ean_party;
     $corr->loadMatchingObject();
     $this->name_assurance = $corr->nom;
     $patient = $xpath->queryUniqueNode("//invoice:patient");
     $this->_avs = $xpath->getValueAttributNode($patient, "ssn");
     if ($company = $xpath->queryUniqueNode("//invoice:contact/invoice:company")) {
         $this->_contact[] = $xpath->queryTextNode("invoice:companyname", $company);
         $this->_contact[] = $xpath->queryTextNode("invoice:department", $company);
         $this->_contact[] = $xpath->queryTextNode("invoice:subaddressing", $company);
         $postal = $xpath->queryUniqueNode("invoice:postal", $company);
         $this->_contact[] = $xpath->queryTextNode("invoice:pobox", $postal);
         $this->_contact[] = $xpath->queryTextNode("invoice:street", $postal);
         $this->_contact[] = $xpath->queryTextNode("invoice:zip", $postal) . " " . $xpath->queryTextNode("invoice:city", $postal);
         $this->_contact[] = $xpath->queryTextNode("invoice:phone", $xpath->queryUniqueNode("invoice:telecom", $company));
         $this->_contact[] = $xpath->queryTextNode("invoice:email", $xpath->queryUniqueNode("invoice:online", $company));
     }
     if ($employee = $xpath->queryUniqueNode("//invoice:contact/invoice:employee")) {
         $this->_contact[] = $xpath->getValueAttributNode($employee, "salutation") . " " . $xpath->queryTextNode("invoice:givenname", $employee) . " " . $xpath->queryTextNode("invoice:familyname", $employee);
         $this->_contact[] = $xpath->queryTextNode("invoice:phone", $xpath->queryUniqueNode("invoice:telecom", $employee));
         $this->_contact[] = $xpath->queryTextNode("invoice:email", $xpath->queryUniqueNode("invoice:online", $employee));
     }
     if ($person = $xpath->queryUniqueNode("//invoice:contact/invoice:person")) {
         $this->_contact[] = $xpath->getValueAttributNode($person, "salutation") . " " . $xpath->queryTextNode("invoice:givenname", $person) . " " . $xpath->queryTextNode("invoice:familyname", $person);
         $this->_contact[] = $xpath->queryTextNode("invoice:phone", $xpath->queryUniqueNode("invoice:subaddressing", $person));
         $postal = $xpath->queryUniqueNode("invoice:postal", $person);
         $this->_contact[] = $xpath->queryTextNode("invoice:pobox", $postal);
         $this->_contact[] = $xpath->queryTextNode("invoice:street", $postal);
         $this->_contact[] = $xpath->queryTextNode("invoice:zip", $postal) . " " . $xpath->queryTextNode("invoice:city", $postal);
         $this->_contact[] = $xpath->queryTextNode("invoice:phone", $xpath->queryUniqueNode("invoice:telecom", $person));
         $this->_contact[] = $xpath->queryTextNode("invoice:email", $xpath->queryUniqueNode("invoice:online", $person));
     }
     $this->_contact = array_filter($this->_contact);
     $pending = $xpath->query("//invoice:pending");
     foreach ($pending as $_pending) {
         $explanation = $xpath->queryTextNode("invoice:explanation", $_pending);
         $this->motif_rejet = "{$explanation} \r\n";
         $this->_commentaire = $explanation;
         $this->_status_in = $xpath->getValueAttributNode($_pending, "status_in");
         $this->_status_out = $xpath->getValueAttributNode($_pending, "status_out");
         $nb_message = 0;
         $messages = $xpath->query("//invoice:message");
         foreach ($messages as $_message) {
             $code = $xpath->getValueAttributNode($_message, "code");
             $text = $xpath->getValueAttributNode($_message, "text");
             if (!$details) {
                 $this->motif_rejet .= "{$code}: {$text} \r\n";
             } else {
                 $this->_erreurs[$nb_message]['code'] = $code;
                 $this->_erreurs[$nb_message]['text'] = $text;
             }
             $nb_message++;
         }
         $this->_pending = 1;
     }
     $rejected = $xpath->query("//invoice:rejected");
     foreach ($rejected as $_rejected) {
         $explanation = $xpath->queryTextNode("invoice:explanation", $_rejected);
         $this->motif_rejet = "{$explanation} \r\n";
         $this->_commentaire = $explanation;
         $this->_status_in = $xpath->getValueAttributNode($_rejected, "status_in");
         $this->_status_out = $xpath->getValueAttributNode($_rejected, "status_out");
         $nb_message = 0;
         $messages = $xpath->query("//invoice:error");
         foreach ($messages as $_message) {
             $code = $xpath->getValueAttributNode($_message, "code");
             $text = $xpath->getValueAttributNode($_message, "text");
             if (!$details) {
                 $this->motif_rejet .= "{$code}: {$text} \r\n";
             } else {
                 $this->_erreurs[$nb_message]['code'] = $code;
                 $this->_erreurs[$nb_message]['text'] = $text;
             }
             if ($error_value = $xpath->getValueAttributNode($_message, "error_value")) {
                 $valid_value = $xpath->getValueAttributNode($_message, "valid_value");
                 if (!$details) {
                     $this->motif_rejet .= "({$error_value}/{$valid_value})";
                 } else {
                     $this->_erreurs[$nb_message]['error_value'] = $error_value;
                     $this->_erreurs[$nb_message]['valid_value'] = $valid_value;
                     $this->_erreurs[$nb_message]['record_id'] = $xpath->getValueAttributNode($_message, "record_id");
                 }
             }
             $nb_message++;
         }
     }
     if (!$details) {
         if ($msg = $this->store()) {
             mbTrace($msg);
         }
     }
 }
 function segmentERR($line)
 {
     mbTrace($line, "Message d'erreur");
     if (!$this->has_header) {
         return false;
     }
     return true;
 }
Exemple #26
0
 * @license OXPL
 */
global $m;
CCanDo::checkAdmin();
$module = CValue::get("module");
$file = isset($_FILES['import']) ? $_FILES['import'] : null;
$fingerprint = $keydata = null;
if ($file) {
    $keydata = file_get_contents($file['tmp_name']);
    if ($module) {
        $path = CAppUI::conf("{$module} gnupg_path");
    }
    $gpg = new gnupg();
    if ($module && $path) {
        putenv("HOME={$path}");
    }
    $gpg->seterrormode(gnupg::ERROR_EXCEPTION);
    try {
        $info = $gpg->import($keydata);
    } catch (Exception $e) {
        mbTrace($e->getMessage());
    }
    if (array_key_exists("fingerprint", $info)) {
        $fingerprint = $info['fingerprint'];
    }
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("fingerprint", $fingerprint);
$smarty->assign("keydata", $keydata);
$smarty->display("ajax_import_key.tpl");
Exemple #27
0
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 24397 $
 */
CCanDo::checkAdmin();
$type = CValue::get("type", "check");
$where = array();
$where["realise"] = " = '1'";
$where[] = "date_realise IS NULL";
$where[] = "author_realise_id IS NULL";
$where[] = "author_id IS NOT NULL";
$task = new CSejourTask();
if ($type == "repair") {
    $tasks = $task->loadList($where, null, 100);
} else {
    $tasks = $task->loadIds($where);
}
CAppUI::stepAjax("Taches à corriger: " . count($tasks), UI_MSG_OK);
if ($type == "repair") {
    $correction = 0;
    foreach ($tasks as $_task) {
        /* @var CSejourTask $_task*/
        $_task->date_realise = $_task->date;
        $_task->author_realise_id = $_task->author_id;
        if ($msg = $_task->store()) {
            mbTrace($msg);
        } else {
            $correction++;
        }
    }
    CAppUI::stepAjax("Taches corrigés: {$correction}", UI_MSG_OK);
}
Exemple #28
0
/**
 * Log shortcut to mbTrace
 * 
 * @param mixed  $var   Data to dump
 * @param string $label Add an optional label
 * 
 * @return int The size of the data written in the log file 
 **/
function mbLog($var, $label = null)
{
    return mbTrace($var, $label, true);
}
 /**
  * @see parent::store()
  */
 function store()
 {
     if (!$this->_id && $this->concept_id) {
         $this->prop = $this->loadRefConcept()->prop;
     }
     // pour la valeur par defaut des enums
     /*if ($this->prop !== null) {
         $this->prop = str_replace("\\", "\\\\", $this->prop);
       }*/
     if (!$this->_id && $this->_make_unique_name) {
         $this->name = self::getUniqueName();
     }
     if ($msg = $this->check()) {
         return $msg;
     }
     /*if (!preg_match('/^[a-z0-9_]+$/i', $this->name)) {
         return "Nom de champ invalide ($this->name)";
       }*/
     $ds = $this->_spec->ds;
     if (!$this->_id) {
         $table_name = $this->getTableName();
         $sql_spec = $this->getSQLSpec(false);
         $query = "ALTER TABLE `{$table_name}` ADD `{$this->name}` {$sql_spec}";
         if (!$ds->query($query)) {
             return "Le champ '{$this->name}' n'a pas pu être ajouté à la table '{$table_name}' (" . $ds->error() . ")";
         }
         $spec_type = $this->_spec_object->getSpecType();
         // ajout de l'index
         if (in_array($spec_type, self::$_indexed_types)) {
             $query = "ALTER TABLE `{$table_name}` ADD INDEX (`{$this->name}`)";
             $ds->query($query);
         }
     } else {
         if ($this->fieldModified("name") || $this->fieldModified("prop")) {
             $table_name = $this->getTableName();
             $sql_spec = $this->getSQLSpec();
             $query = "ALTER TABLE `{$table_name}` CHANGE `{$this->_old->name}` `{$this->name}` {$sql_spec}";
             if (!$ds->query($query)) {
                 return "Le champ '{$this->name}' n'a pas pu être mis à jour (" . $ds->error() . ")";
             }
         }
     }
     $locale = $this->_locale;
     $locale_desc = $this->_locale_desc;
     $locale_court = $this->_locale_court;
     $triggered_data = $this->_triggered_data;
     if ($msg = parent::store()) {
         return $msg;
     }
     // form triggers
     if ($triggered_data) {
         $triggered_object = json_decode($triggered_data, true);
         if (is_array($triggered_object)) {
             foreach ($triggered_object as $_value => $_class_trigger_id) {
                 $trigger = new CExClassFieldTrigger();
                 $trigger->ex_class_field_id = $this->_id;
                 $trigger->trigger_value = $_value;
                 $trigger->loadMatchingObject();
                 if ($_class_trigger_id) {
                     $trigger->ex_class_triggered_id = $_class_trigger_id;
                     $trigger->store();
                 } else {
                     $trigger->delete();
                 }
             }
         }
     }
     // self translations
     if ($locale || $locale_desc || $locale_court) {
         $trans = $this->loadRefTranslation();
         $trans->std = $locale;
         $trans->desc = $locale_desc;
         $trans->court = $locale_court;
         if ($msg = $trans->store()) {
             mbTrace($msg, get_class($this), true);
         }
     }
     return null;
 }
 /**
  * Execute a any query
  * 
  * @param string $query SQL Query
  * 
  * @return resource|bool The result resource on SELECT, true on others, false if failed
  **/
 function exec($query)
 {
     // Query colouring
     if (CSQLDataSource::$trace) {
         echo utf8_decode(CMbString::highlightCode("sql", $query, false, "white-space: pre-wrap;"));
     }
     // Chrono
     $this->chrono->start();
     $result = $this->query($query);
     $this->chrono->stop();
     // Error handling
     if (!$result) {
         // On slave error, retry exact same request on std
         if ($this->dsn == "slave") {
             mbTrace("slave error handling");
             $std = self::$dataSources["std"];
             $std->chrono->start();
             $result = $this->query($query);
             $std->chrono->stop();
             mbTrace($result, "std result");
             if ($result) {
                 mbTrace("Disabling slave");
                 CView::disableSlave();
                 return $result;
             }
         }
         $error = $this->error();
         trigger_error("SQL Error: {$error} for DSN '{$this->dsn}' on SQL query <em>{$query}</em>", E_USER_WARNING);
         return false;
     }
     // Chrono messaging
     if (CSQLDataSource::$trace) {
         $step = $this->chrono->latestStep * 1000;
         $total = $this->chrono->total * 1000;
         $pace = floor(2 * log10($step));
         $pace = max(0, min(6, $pace));
         $message = "query-pace-{$pace}";
         $type = floor(($pace + 3) / 2);
         CAppUI::stepMessage($type, $message, $this->dsn, $step, $total);
     }
     if (CSQLDataSource::$report) {
         $hash = self::hashQuery($query);
         if (!isset(self::$report_data[$hash])) {
             self::$report_data[$hash] = array();
         }
         self::$report_data[$hash][] = array($this->chrono->latestStep * 1000, $query);
     }
     return $result;
 }