Ejemplo n.º 1
0
     $format_config->sender_class = $actor->_class;
     $format_config->sender_id = $actor->_id;
 }
 $dom = new CMbXMLDocument();
 $dom->loadXML($contents);
 $root_name = $dom->documentElement->nodeName;
 $fields = $format_config->getPlainFields();
 unset($fields[$format_config->_spec->key]);
 unset($fields["sender_id"]);
 unset($fields["sender_class"]);
 if ($root_name == $format_config->_class) {
     $xpath = new CMbXPath($dom);
     $nodeList = $xpath->query("//{$root_name}/*");
     $array_configs = array();
     foreach ($nodeList as $_node) {
         $config = $xpath->getValueAttributNode($_node, "config");
         $value = $xpath->getValueAttributNode($_node, "value");
         $array_configs[$config] = $value;
     }
     if ($count = array_diff_key($array_configs, $fields)) {
         CAppUI::setMsg("Trop de données ('" . count($array_configs) . "') par rapport aux \n        champs de l'objet ('" . count($fields) . "')", UI_MSG_ERROR);
     } else {
         foreach ($array_configs as $key => $value) {
             $format_config->{$key} = $value;
             if ($msg = $format_config->store()) {
                 CAppUI::setMsg("Erreur lors de l'import de la configuration : " . $msg, UI_MSG_ERROR);
             } else {
                 CAppUI::setMsg("Configuration correctement importée");
             }
         }
     }
 /**
  * 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);
         }
     }
 }