Analiza un mensaje XML (por defecto la respuesta)
496551
def AnalizarXml(self, xml=""):
        ""
        try:
            if not xml:
                xml = self.XmlResponse
            self.xml = SimpleXMLElement(xml)
            return True
        except Exception, e:
            self.Excepcion = u"%s" % (e)
            return False
944027
public function xml()
    {
        foreach ($this->_result as $disk_items) {
            if (isset($disk_items['Name']) && (trim($disk_items['Name']) !== '')) {
                $xmlstablebit_disk = $this->xml->addChild("Disk");
                foreach ($this->stablebit_items as $item) {
                    if (isset($disk_items[$item]) && (($itemvalue=$disk_items[$item]) !== '') &&
                    (($item !== 'SerialNumber') || (defined('PSI_PLUGIN_STABLEBIT_SHOW_SERIAL') && (PSI_PLUGIN_STABLEBIT_SHOW_SERIAL === true)))) {
                        $xmlstablebit_disk ->addAttribute($item, $itemvalue);
                    }
                }
            }
        }

        return $this->xml->getSimpleXmlElement();
    }
861650
function xmlString( )
    {
        $doc = new DOMDocument( '1.0', 'utf-8' );

        $root = $doc->createElement( "ezrangeoption" );
        $root->setAttribute( "start_value", $this->StartValue );
        $root->setAttribute( "stop_value", $this->StopValue );
        $root->setAttribute( "step_value", $this->StepValue );
        $doc->appendChild( $root );

        $name = $doc->createElement( "name", $this->Name );
        $root->appendChild( $name );

        $xml = $doc->saveXML();

        return $xml;
    }
156788
public function args_check()
    {
        // archivo
        if (!$this->args['xml'] or !is_readable($this->args['xml'])) {
            $this->error('Debe especificar archivo XML de entrada válido');
        }
        // directorio de salida
        if (!$this->args['dir'] or (!is_dir($this->args['dir']) and !mkdir($this->args['dir']))) {
            $this->error('Debe especificar directorio válido para dejar los archivos PDF generados');
        }
    }
106093
protected function getFeedXml()
    {
        $client = $this->curlFactory->create();
        $client->setConfig($this->getCurlConfig());

        $client->write(\Zend_Http_Client::GET, self::ENDPOINT, '1.0');

        $response = $client->read();
        $client->close();

        if (false !== $response) {
            $data = preg_split('/^\r?$/m', $response, 2);

            try {
                $xml = new \SimpleXMLElement(trim($data[1]));
            } catch (\Exception $e) {
                return false;
            }

            return $xml;
        }

        return false;
    }
1245756
public function asXml() {
		$exception = $this->_exception;
		$options   = $this->_options;
		$builder   = new Errbit_XmlBuilder();
		$self      = $this;

		return $builder->tag(
			'notice',
			array('version' => Errbit::API_VERSION),
			function($notice) use ($exception, $options, $self) {
				$notice->tag('api-key',  $options['api_key']);
				$notice->tag('notifier', function($notifier) {
					$notifier->tag('name',    Errbit::PROJECT_NAME);
					$notifier->tag('version', Errbit::VERSION);
					$notifier->tag('url',     Errbit::PROJECT_URL);
				});

				$notice->tag('error', function($error) use ($exception, $self) {
					$klass = Errbit_Notice::className($exception);
					$error->tag('class',     $self->filterTrace($klass));
					$error->tag('message',   $self->filterTrace(sprintf('%s: %s', $klass, $exception->getMessage())));
					$error->tag('backtrace', function($backtrace) use ($exception, $self) {
						$trace = $exception->getTrace();

						$file1 = $exception->getFile();
						$backtrace->tag('line', array(
							'number' => $exception->getLine(),
							'file' => !empty($file1) ? $self->filterTrace($file1) : '<unknown>',
							'method' =>  "<unknown>"
						));

						// if there is no trace we should add an empty element
						if (empty($trace)) {
							$backtrace->tag(
								'line',
								array(
									 'number' => '',
									 'file' => '',
									 'method' => ''
								)
							);
						} else {
							foreach ($trace as $frame) {
								$backtrace->tag(
									'line',
									array(
										'number' => isset($frame['line']) ? $frame['line'] : 0,
										'file'   => isset($frame['file']) ? $self->filterTrace($frame['file']) : '<unknown>',
										'method' => $self->filterTrace(Errbit_Notice::formatMethod($frame))
									)
								);
							}
						}
					});
				});

				if (!empty($options['url'])
					|| !empty($options['controller'])
					|| !empty($options['action'])
					|| !empty($options['parameters'])
					|| !empty($options['session_data'])
					|| !empty($options['cgi_data'])) {
					$notice->tag('request', function($request) use ($options) {
						$request->tag('url',       !empty($options['url']) ? $options['url'] : '');
						$request->tag('component', !empty($options['controller']) ? $options['controller'] : '');
						$request->tag('action',    !empty($options['action']) ? $options['action'] : '');
						if (!empty($options['parameters'])) {
							$request->tag('params', function($params) use ($options) {
								Errbit_Notice::xmlVarsFor($params, $options['parameters']);
							});
						}

						if (!empty($options['session_data'])) {
							$request->tag('session', function($session) use ($options) {
								Errbit_Notice::xmlVarsFor($session, $options['session_data']);
							});
						}

						if (!empty($options['cgi_data'])) {
							$request->tag('cgi-data', function($cgiData) use ($options) {
								Errbit_Notice::xmlVarsFor($cgiData, $options['cgi_data']);
							});
						}
					});
				}

				$notice->tag('server-environment', function($env) use ($options) {
					$env->tag('project-root',     $options['project_root']);
					$env->tag('environment-name', $options['environment_name']);
					$env->tag('hostname',         $options['hostname']);
				});
			}
		)->asXml();
	}
1248577
public function parse()
    {
        if (!is_string($this->data)) {
            throw new \RuntimeException('The given data is no valid string');
        }
        libxml_use_internal_errors(true);
        $xml = simplexml_load_string($this->data);
        if ($xml === false) {
            throw new \RuntimeException('Error during the loading of the XML file');
        }
        if (!isset($xml->executables, $xml->excludes)) {
            throw new \RuntimeException('Missing configuration elements');
        }

        foreach ($xml->excludes->children()->file as $file) {
            $this->config->addExcludedFile((string) $file);
        }

        foreach ($xml->excludes->children()->dir as $dir) {
            $this->config->addExcludedDir((string) $dir);
        }

        foreach ($xml->executables->children() as $file) {
            $this->config->addExecutableFile((string) $file);
        }

        return $this->config;
    }
15592
public function createXmlDocument()
    {
        $dom = new \DOMDocument('1.0', 'utf-8');
        $dom->formatOutput = true;
        $rss = $dom->appendChild($dom->createElement('rss'));

        $version = $dom->createAttribute('version');
        $version->appendChild($dom->createTextNode('2.0'));
        $rss->appendChild($version);

        $datetime = $this->publishDate ? $this->publishDate : new \DateTime('now');
        $datetime = $datetime->format('M d Y H:i:s');

        $channel = $rss->appendChild($dom->createElement('channel'));
        $channel->appendChild($dom->createElement('title', $this->title));
        $channel->appendChild($dom->createElement('link', $this->link));
        $channel->appendChild($dom->createElement('description', $this->description));
        $channel->appendChild($dom->createElement('lastBuildDate', $datetime));
        $channel->appendChild($dom->createElement('pubDate', $datetime));

        foreach ($this->items as $item) {
            $description = $item->getDescription();
            $description = str_replace(array("\r\n", "\r", "\n"), "<br /> ", $description);
            $description = html_entity_decode(strip_tags($description), ENT_QUOTES, 'utf-8');

            $node = $channel->appendChild($dom->createElement('item'));
            $node->appendChild($dom->createElement('title', $item->getTitle()));
            $node->appendChild($dom->createElement('link', $item->getLink()));
            $node->appendChild($dom->createElement('description', $description));
            $node->appendChild($dom->createElement('pubDate', $item->getPublishDate()));
        }

        return $dom->saveXML();
    }
269503
public function getHasta()
    {
        if (!$this->xml) {
            return false;
        }
        $H = $this->xml->getElementsByTagName('H')->item(0);
        return $H ? (int)$H->nodeValue : false;
    }
260344
function to_xml_start(){
		if ($this->skip) return "";
		
		$str1="<item id='".$this->xmlentities($this->get_id())."' text='".$this->xmlentities($this->data[$this->config->text[0]["name"]])."' ";
		if ($this->has_kids()==true) $str1.="child='".$this->has_kids()."' ";
		if ($this->im0) $str1.="im0='".$this->im0."' ";
		if ($this->im1) $str1.="im1='".$this->im1."' ";
		if ($this->im2) $str1.="im2='".$this->im2."' ";
		if ($this->check) $str1.="checked='".$this->check."' ";
		foreach ($this->attrs as $key => $value)
			$str1.=$key."='".$this->xmlentities($value)."' ";
		$str1.=">";
		if ($this->userdata !== false)
			foreach ($this->userdata as $key => $value)
				$str1.="<userdata name='".$key."'><![CDATA[".$value."]]></userdata>";
			
		return $str1;
	}
43962
protected function parseDataFromResponse()
    {
        $xml = new \SimpleXMLElement($this->rawResponse->body);
        $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : "";
        $objectList = $this->parseObjectList($xml, $encodingType);
        $prefixList = $this->parsePrefixList($xml, $encodingType);
        $bucketName = isset($xml->Name) ? strval($xml->Name) : "";
        $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : "";
        $prefix = OssUtil::decodeKey($prefix, $encodingType);
        $marker = isset($xml->Marker) ? strval($xml->Marker) : "";
        $marker = OssUtil::decodeKey($marker, $encodingType);
        $maxKeys = isset($xml->MaxKeys) ? intval($xml->MaxKeys) : 0;
        $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : "";
        $delimiter = OssUtil::decodeKey($delimiter, $encodingType);
        $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : "";
        $nextMarker = isset($xml->NextMarker) ? strval($xml->NextMarker) : "";
        $nextMarker = OssUtil::decodeKey($nextMarker, $encodingType);
        return new ObjectListInfo($bucketName, $prefix, $marker, $nextMarker, $maxKeys, $delimiter, $isTruncated, $objectList, $prefixList);
    }
1087751
def AnalizarXml(self, xml=""):
        ""
        try:
            if not xml or xml=='XmlResponse':
                xml = self.XmlResponse 
            elif xml=='XmlRequest':
                xml = self.XmlRequest 
            self.xml = SimpleXMLElement(xml)
            return True
        except Exception, e:
            self.Excepcion = traceback.format_exception_only( sys.exc_type, sys.exc_value)[0]
            return False
24382
private function _xmlbody()
    {
        $dom = new DOMDocument('1.0', 'UTF-8');
        $root = $dom->createElement("tns:phpsysinfo");
        $root->setAttribute('xmlns:tns', 'http://phpsysinfo.sourceforge.net/');
        $root->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
        $root->setAttribute('xsi:schemaLocation', 'http://phpsysinfo.sourceforge.net/ phpsysinfo3.xsd');
        $dom->appendChild($root);
        $this->_xml = new SimpleXMLExtended(simplexml_import_dom($dom), $this->_sysinfo->getEncoding());

        $generation = $this->_xml->addChild('Generation');
        $generation->addAttribute('version', PSI_VERSION_STRING);
        $generation->addAttribute('timestamp', time());
        $options = $this->_xml->addChild('Options');
        $options->addAttribute('tempFormat', defined('PSI_TEMP_FORMAT') ? strtolower(PSI_TEMP_FORMAT) : 'c');
        $options->addAttribute('byteFormat', defined('PSI_BYTE_FORMAT') ? strtolower(PSI_BYTE_FORMAT) : 'auto_binary');
        $options->addAttribute('datetimeFormat', defined('PSI_DATETIME_FORMAT') ? strtolower(PSI_DATETIME_FORMAT) : 'utc');
        if (defined('PSI_REFRESH')) {
            $options->addAttribute('refresh',  max(intval(PSI_REFRESH), 0));
        } else {
            $options->addAttribute('refresh', 60000);
        }
        if (defined('PSI_FS_USAGE_THRESHOLD')) {
            if ((($fsut = intval(PSI_FS_USAGE_THRESHOLD)) >= 1) && ($fsut <= 99)) {
                $options->addAttribute('threshold', $fsut);
            }
        } else {
            $options->addAttribute('threshold', 90);
        }
        if (count($this->_plugins) > 0) {
            if ($this->_plugin_request) {
                $plug = $this->_xml->addChild('UsedPlugins');
                $plug->addChild('Plugin')->addAttribute('name', $this->_plugin);
            } elseif ($this->_complete_request) {
                $plug = $this->_xml->addChild('UsedPlugins');
                foreach ($this->_plugins as $plugin) {
                    $plug->addChild('Plugin')->addAttribute('name', $plugin);
                }
/*
            } else {
                $plug = $this->_xml->addChild('UnusedPlugins');
                foreach ($this->_plugins as $plugin) {
                    $plug->addChild('Plugin')->addAttribute('name', $plugin);
                }
*/
            }
        }
    }
1217424
function inputXML()
    {
        $contentObjectAttribute = $this->ContentObjectAttribute;
        $contentObjectAttributeID = $contentObjectAttribute->attribute( 'id' );

        $originalInput = 'originalInput_' . $contentObjectAttributeID;
        $isInputValid = 'isInputValid_' . $contentObjectAttributeID;

        if ( isset( $GLOBALS[$isInputValid] ) and $GLOBALS[$isInputValid] == false )
        {
            $output = $GLOBALS[$originalInput];
        }
        else
        {
            $dom = new DOMDocument( '1.0', 'utf-8' );
            $success = $dom->loadXML( $this->XMLData );

            $editOutput = new eZSimplifiedXMLEditOutput();
            $dom->formatOutput = true;
            if ( eZDebugSetting::isConditionTrue( 'kernel-datatype-ezxmltext', eZDebug::LEVEL_DEBUG ) )
                eZDebug::writeDebug( $dom->saveXML(), eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext', __METHOD__ . ' xml string stored in database' ) );
            $output = $editOutput->performOutput( $dom );
        }
        return $output;
    }
646977
public function xml2query()
    {
        if (array_key_exists("CogModule", $this->data)) {
            $q = &$this->data["CogModule"];
        } else {
            $q = &$this->data["Report"];
        }

        $criteria_links = array();

        // Generate Output Information...
        $ds = false;
        if (!$q) {
            return;
        }

        foreach ($q as $cogquery) {
            // Set Query Attributes
            foreach ($cogquery["Format"] as $att => $val) {
                $this->query->setAttribute($att, $val);
            }

            // Set DataSource
            if (isset($cogquery["Datasource"])) {
                foreach ($cogquery["Datasource"] as $att => $val) {
                    //if ( $att == "SourceType" )
                    //$this->query->source_type = $val;

                    if ($att == "SourceConnection") {
                        // No longer relevant - connections are not supplied in xml files
                    }
                }
            }

            // Set Query Columns
            if (!($ef = &$this->getArrayElement($cogquery, "EntryForm"))) {
                $this->ErrorMsg = "No EntryForm tag within Format";
                return false;
            }

            if (!($qu = &$this->getArrayElement($ef, "Query"))) {
                $this->ErrorMsg = "No Query tag within EntryForm";
                return false;
            }

            $this->query->table_text = $this->getArrayElement($qu, "TableSql");
            $this->query->where_text = $this->getArrayElement($qu, "WhereSql");
            $this->query->group_text = $this->getArrayElement($qu, "GroupSql");
            $this->query->rowselection = $this->getArrayElement($qu, "RowSelection");
            $has_cols = true;

            if (($qc = &$this->getArrayElement($qu, "SQL"))) {
                $this->query->sql_raw = $this->getArrayElement($qc, "SQLRaw");
            }

            if (!($qc = &$this->getArrayElement($qu, "QueryColumns"))) {
                $this->ErrorMsg = "No QueryColumns tag within Query";
                $has_cols = false;
            }

            // Generate QueryColumn for each column found
            if ($has_cols) {
                foreach ($qc as $col) {
                    $in_query = true;
                    if (!$col["ColumnName"]) {
                        $in_query = false;
                    }

                    $this->query->createCriteriaColumn
                    (
                        $col["Name"],
                        $col["TableName"],
                        $col["ColumnName"],
                        $col["ColumnType"],
                        $col["ColumnLength"],
                        "###.##",
                        $in_query
                    );

                    // Set any Attributes
                    if (($fm = &$this->getArrayElement($col, "Format"))) {
                        foreach ($fm as $att => $val) {
                            $this->query->setColumnAttribute($col["Name"], $att, $val);
                        }
                    }
                }

                // Generate Order By List
                if (($oc = &$this->getArrayElement($qu, "OrderColumns"))) {
                    // Generate QueryColumn for each column found
                    foreach ($oc as $col) {
                        if (!$col["Name"]) {
                            return;
                        }

                        $this->query->createQueryColumn
                        (
                            $col["Name"],
                            $col["OrderType"]
                        );
                    }
                }

                // Generate Query Assignments
                if (($as = &$this->getArrayElement($ef, "Assignments"))) {
                    foreach ($as as $col) {
                        if (array_key_exists("AssignName", $col)) {
                            $this->query->addAssignment($col["AssignName"], $col["Expression"], $col["Condition"]);
                        } else {
                            $this->query->addAssignment($col["Name"], $col["Expression"], $col["Condition"]);
                        }

                    }
                }
            }

            // Generate Query Assignments
            if (($pq = &$this->getArrayElement($qu, "PreSQLS"))) {
                foreach ($pq as $col) {
                    $this->query->addPreSql($col["SQLText"]);
                }
            }

            // Generate Output Information...
            if (($op = &$this->getArrayElement($ef, "Output"))) {
                // Generate Page Headers
                if (($ph = $this->getArrayElement($op, "PageHeaders"))) {
                    foreach ($ph as $k => $phi) {
                        $this->query->createPageHeader($k, $phi["LineNumber"], $phi["HeaderText"]);
                        if (($fm = &$this->getArrayElement($phi, "Format"))) {
                            foreach ($fm as $att => $val) {
                                $this->query->setPageHeaderAttribute($k, $att, $val);
                            }
                        }

                    }
                }

                // Generate Page Footers
                if (($ph = $this->getArrayElement($op, "PageFooters"))) {
                    foreach ($ph as $k => $phi) {
                        $this->query->createPageFooter($k, $phi["LineNumber"], $phi["FooterText"]);
                        if (($fm = &$this->getArrayElement($phi, "Format"))) {
                            foreach ($fm as $att => $val) {
                                $this->query->setPageFooterAttribute($k, $att, $val);
                            }
                        }

                    }
                }

                // Generate Display Orders
                if ($has_cols && ($ph = $this->getArrayElement($op, "DisplayOrders"))) {
                    foreach ($ph as $k => $phi) {
                        $this->query->setColumnOrder($phi["ColumnName"], $phi["OrderNumber"]);
                    }
                }

                if ($has_cols && ($ph = $this->getArrayElement($op, "Groups"))) {
                    foreach ($ph as $k => $phi) {
                        if (array_key_exists("GroupName", $phi)) {
                            $gpname = $phi["GroupName"];
                        } else {
                            $gpname = $phi["Name"];
                        }

                        $grn = $this->query->createGroup($gpname);

                        if (array_key_exists("BeforeGroupHeader", $phi)) {
                            $grn->setAttribute("before_header", $phi["BeforeGroupHeader"]);
                            $grn->setAttribute("after_header", $phi["AfterGroupHeader"]);
                            $grn->setAttribute("before_trailer", $phi["BeforeGroupTrailer"]);
                            $grn->setAttribute("after_trailer", $phi["AfterGroupTrailer"]);
                            $grn->setFormat("before_header", $phi["BeforeGroupHeader"]);
                            $grn->setFormat("after_header", $phi["AfterGroupHeader"]);
                            $grn->setFormat("before_trailer", $phi["BeforeGroupTrailer"]);
                            $grn->setFormat("after_trailer", $phi["AfterGroupTrailer"]);
                        }

                        if (($gp = &$this->getArrayElement($phi, "GroupHeaders"))) {
                            foreach ($gp as $att => $val) {
                                if (!isset($val["GroupHeaderCustom"])) {
                                    $val["GroupHeaderCustom"] = false;
                                }

                                if (!isset($val["ShowInHTML"])) {
                                    $val["ShowInHTML"] = "yes";
                                }

                                if (!isset($val["ShowInPDF"])) {
                                    $val["ShowInPDF"] = "yes";
                                }

                                $this->query->createGroupHeader($gpname, $val["GroupHeaderColumn"], $val["GroupHeaderCustom"], $val["ShowInHTML"], $val["ShowInPDF"]);
                            }
                        }

                        if (($gp = &$this->getArrayElement($phi, "GroupTrailers"))) {
                            foreach ($gp as $att => $val) {
                                if (!isset($val["GroupTrailerCustom"])) {
                                    $val["GroupTrailerCustom"] = false;
                                }

                                if (!isset($val["ShowInHTML"])) {
                                    $val["ShowInHTML"] = "yes";
                                }

                                if (!isset($val["ShowInPDF"])) {
                                    $val["ShowInPDF"] = "yes";
                                }

                                $this->query->createGroupTrailer($gpname, $val["GroupTrailerDisplayColumn"],
                                    $val["GroupTrailerValueColumn"],
                                    $val["GroupTrailerCustom"], $val["ShowInHTML"], $val["ShowInPDF"]);
                            }
                        }

                    }
                }

                // Generate Graphs
                if ($has_cols && ($gph = $this->getArrayElement($op, "Graphs"))) {
                    foreach ($gph as $k => $gphi) {
                        $ka = array_keys($gphi);
                        $gph = &$this->query->createGraph();

                        $gph->setGraphColumn($gphi["GraphColumn"]);

                        $gph->setTitle($gphi["Title"]);
                        $gph->setXtitle($gphi["XTitle"]);
                        $gph->setXlabelColumn($gphi["XLabelColumn"]);
                        $gph->setYtitle($gphi["YTitle"]);
                        //$gph->setYlabelColumn($gphi["YLabelColumn"]);
                        //////HERE!!!
                        if (array_key_exists("GraphWidth", $gphi)) {
                            $gph->setWidth($gphi["GraphWidth"]);
                            $gph->setHeight($gphi["GraphHeight"]);
                            $gph->setWidthPdf($gphi["GraphWidthPDF"]);
                            $gph->setHeightPdf($gphi["GraphHeightPDF"]);
                        } else {
                            $gph->setWidth($gphi["Width"]);
                            $gph->setHeight($gphi["Height"]);
                        }

                        if (array_key_exists("GraphColor", $gphi)) {
                            $gph->setGraphColor($gphi["GraphColor"]);
                            $gph->setGrid($gphi["GridPosition"],
                                $gphi["XGridDisplay"], $gphi["XGridColor"],
                                $gphi["YGridDisplay"], $gphi["YGridColor"]
                            );
                            $gph->setTitleFont($gphi["TitleFont"], $gphi["TitleFontStyle"],
                                $gphi["TitleFontSize"], $gphi["TitleColor"]);
                            $gph->setXtitleFont($gphi["XTitleFont"], $gphi["XTitleFontStyle"],
                                $gphi["XTitleFontSize"], $gphi["XTitleColor"]);
                            $gph->setYtitleFont($gphi["YTitleFont"], $gphi["YTitleFontStyle"],
                                $gphi["YTitleFontSize"], $gphi["YTitleColor"]);
                            $gph->setXaxis($gphi["XTickInterval"], $gphi["XTickLabelInterval"], $gphi["XAxisColor"]);
                            $gph->setYaxis($gphi["YTickInterval"], $gphi["YTickLabelInterval"], $gphi["YAxisColor"]);
                            $gph->setXaxisFont($gphi["XAxisFont"], $gphi["XAxisFontStyle"],
                                $gphi["XAxisFontSize"], $gphi["XAxisFontColor"]);
                            $gph->setYaxisFont($gphi["YAxisFont"], $gphi["YAxisFontStyle"],
                                $gphi["YAxisFontSize"], $gphi["YAxisFontColor"]);
                            $gph->setMarginColor($gphi["MarginColor"]);
                            $gph->setMargins($gphi["MarginLeft"], $gphi["MarginRight"],
                                $gphi["MarginTop"], $gphi["MarginBottom"]);
                        }
                        foreach ($gphi["Plots"] as $pltk => $pltv) {
                            $pl = &$gph->createPlot($pltv["PlotColumn"]);
                            $pl["type"] = $pltv["PlotType"];
                            $pl["fillcolor"] = $pltv["FillColor"];
                            $pl["linecolor"] = $pltv["LineColor"];
                            $pl["legend"] = $pltv["Legend"];
                        }
                    }
                }

            } // Output

            // Check for Criteria Items ...

            if (($crt = &$this->getArrayElement($ef, "Criteria"))) {
                foreach ($crt as $ci) {
                    $critnm = $this->getArrayElement($ci, "Name");

                    $crittb = $this->getArrayElement($ci, "QueryTableName");
                    $critcl = $this->getArrayElement($ci, "QueryColumnName");
                    $linked_report = $this->getArrayElement($ci, "LinkToReport");
                    $linked_report_item = $this->getArrayElement($ci, "LinkToReportItem");

                    // If we are not designing a report then
                    // replace a linked criteria with the criteria
                    // item it links to from another report
                    if ($linked_report && $this->query->execute_mode != "MAINTAIN") {
                        $q = new Reportico();
                        $q->reports_path = $q->projects_folder . "/" . ReporticoApp::getConfig("project");
                        $reader = new XmlReader($q, $linked_report, false);
                        $reader->xml2query();

                        foreach ($q->lookup_queries as $k => $v) {

                            $found = false;
                            foreach ($this->query->columns as $querycol) {
                                if ($querycol->query_name == $v->query_name) {
                                    $found = true;
                                }
                            }

                            $qu = new Reportico();
                            if ($linked_report_item == $v->query_name) {
                                $this->query->lookup_queries[$v->query_name] = $v;
                            }

                        }
                        continue;
                    }

                    if ($crittb) {
                        $critcl = $crittb . "." . $critcl;
                        $crittb = "";
                    }
                    $crittp = $this->getArrayElement($ci, "CriteriaType");
                    $critlt = $this->getArrayElement($ci, "CriteriaList");
                    $crituse = $this->getArrayElement($ci, "Use");
                    $critds = $this->getArrayElement($ci, "CriteriaDisplay");
                    $critexp = $this->getArrayElement($ci, "ExpandDisplay");
                    $critmatch = $this->getArrayElement($ci, "MatchColumn");
                    $critdefault = $this->getArrayElement($ci, "CriteriaDefaults");
                    $crithelp = $this->getArrayElement($ci, "CriteriaHelp");
                    $crittitle = $this->getArrayElement($ci, "Title");
                    $crit_required = $this->getArrayElement($ci, "CriteriaRequired");
                    $crit_hidden = $this->getArrayElement($ci, "CriteriaHidden");
                    $crit_display_group = $this->getArrayElement($ci, "CriteriaDisplayGroup");
                    $crit_lookup_return = $this->getArrayElement($ci, "ReturnColumn");
                    $crit_lookup_display = $this->getArrayElement($ci, "DisplayColumn");
                    $crit_criteria_display = $this->getArrayElement($ci, "OverviewColumn");

                    if ($crittp == "ANYCHAR") {
                        $crittp = "TEXTFIELD";
                    }

                    if ($critds == "ANYCHAR") {
                        $critds = "TEXTFIELD";
                    }

                    if ($critexp == "ANYCHAR") {
                        $critexp = "TEXTFIELD";
                    }

                    // Generate criteria lookup info unless its a link to a criteria in a nother report
                    if (!$linked_report && !($ciq = &$this->getArrayElement($ci, "Query"))) {
                        continue;
                    }

                    $critquery = new Reportico();

                    // Generate Criteria Query Columns
                    if (!$linked_report && ($ciqc = &$this->getArrayElement($ciq, "QueryColumns"))) {
                        foreach ($ciqc as $ccol) {
                            $in_query = true;
                            if (!$ccol["ColumnName"]) {
                                $in_query = false;
                            }

                            $critquery->createCriteriaColumn
                            (
                                $ccol["Name"],
                                $ccol["TableName"],
                                $ccol["ColumnName"],
                                $ccol["ColumnType"],
                                $ccol["ColumnLength"],
                                "###.##",
                                $in_query
                            );
                        }
                    }
                    // Generate Order By List
                    if (!$linked_report && ($coc = &$this->getArrayElement($ciq, "OrderColumns"))) {
                        // Generate QueryColumn for each column found
                        foreach ($coc as $col) {
                            $critquery->createOrderColumn
                            (
                                $col["Name"],
                                $col["OrderType"]
                            );
                        }
                    }

                    if (!$linked_report && ($as = &$this->getArrayElement($ciq, "Assignments"))) {
                        foreach ($as as $ast) {
                            if (array_key_exists("AssignName", $ast)) {
                                $critquery->addAssignment($ast["AssignName"], $ast["Expression"], $ast["Condition"]);
                            } else {
                                $critquery->addAssignment($ast["Name"], $ast["Expression"], $ast["Condition"]);
                            }

                        }
                    }

                    // Generate Criteria Links  In Array for later use
                    if (!$linked_report && ($cl = &$this->getArrayElement($ci, "CriteriaLinks"))) {
                        foreach ($cl as $clitem) {
                            $criteria_links[] = array(
                                "LinkFrom" => $clitem["LinkFrom"],
                                "LinkTo" => $clitem["LinkTo"],
                                "LinkClause" => $clitem["LinkClause"],
                            );
                        }
                    }

                    // Set Query SQL Text
                    if (!$linked_report) {
                        $critquery->table_text = $this->getArrayElement($ciq, "TableSql");
                        $critquery->where_text = $this->getArrayElement($ciq, "WhereSql");
                        $critquery->group_text = $this->getArrayElement($ciq, "GroupSql");
                        $critquery->sql_raw = $this->getArrayElement($ciq, "SQLRaw");
                        $critquery->rowselection = $this->getArrayElement($ciq, "RowSelection");
                    }
                    $critquery->setLookupReturn($crit_lookup_return);
                    $critquery->setLookupDisplay($crit_lookup_display, $crit_criteria_display);
                    $critquery->setLookupExpandMatch($critmatch);
                    $this->query->setCriteriaLookup($critnm, $critquery, $crittb, $critcl);
                    $this->query->setCriteriaInput($critnm, $crittp, $critds, $critexp, $crituse);
                    $this->query->setCriteriaLinkReport($critnm, $linked_report, $linked_report_item);
//echo "SET $critnm $crit_required<BR>";
                    $this->query->setCriteriaDefaults($critnm, $critdefault);
                    $this->query->setCriteriaList($critnm, $critlt);
                    //var_dump($crit_required);
                    $this->query->setCriteriaRequired($critnm, $crit_required);
                    $this->query->setCriteriaHidden($critnm, $crit_hidden);
                    $this->query->setCriteriaDisplayGroup($critnm, $crit_display_group);
                    //$this->query->setCriteriaHelp($critnm, $crithelp);
                    $this->query->setCriteriaAttribute($critnm, "column_title", $crittitle);

                    $this->query->setCriteriaHelp($critnm, $crithelp);

                } // End Criteria Item

                // Set up any Criteria Links
                foreach ($criteria_links as $cl) {
                    $this->query->set_criteria_link($cl["LinkFrom"], $cl["LinkTo"], $cl["LinkClause"]);
                }
            }
        }

    }
928883
private function respaldarDocumentosEmitidos()
    {
        // obtener DTE emitidos en el Portal MIPYME del SII
        $this->log('Descargando documentos emitidos');
        $emitidos = $this->LibreDTE->post('/utilidades/sii/mipyme_dte_emitidos/'.$this->args['contribuyente'], [
            'auth'=>[
                'rut' => $this->args['usuario'],
                'clave' => $this->args['clave'],
            ],
        ]);
        if ($emitidos['status']['code']!=200) {
            $this->log(' [error] Al obtener DTE emitidos en Portal MIPYME del SII: '.$emitidos['body']);
            return;
        }
        file_put_contents($this->args['salida'].'/emitidos_'.$this->args['contribuyente'].'.json', json_encode($emitidos['body'], JSON_PRETTY_PRINT));
        // descargar PDF y XML de los documentos
        $n_docs = count($emitidos['body']);
        $i = 0;
        foreach ($emitidos['body'] as $doc) {
            $i++;
            $this->log('Descargando PDF y XML '.$this->num($i).'/'.$this->num($n_docs).' '.$doc['dte'].' #'.$doc['folio']);
            // descargar PDF
            $pdf = $this->LibreDTE->post('/utilidades/sii/mipyme_dte_emitido_pdf/'.$this->args['contribuyente'].'/'.$doc['codigo'], [
                'auth'=>[
                    'rut' => $this->args['usuario'],
                    'clave' => $this->args['clave'],
                ],
            ]);
            if ($pdf['status']['code']!=200) {
                $this->log(' [error] Al obtener el PDF '.$doc['codigo'].': '.$pdf['body']);
            } else {
                file_put_contents($this->args['salida'].'/emitidos/dte_'.$this->args['contribuyente'].'_T'.$this->getCodigoDTE($doc['dte']).'F'.$doc['folio'].'.pdf', $pdf['body']);
            }
            // descargar XML
            $xml = $this->LibreDTE->post('/utilidades/sii/mipyme_dte_emitido_xml/'.$this->args['contribuyente'].'/'.$this->getCodigoDTE($doc['dte']).'/'.$doc['folio'], [
                'auth'=>[
                    'rut' => $this->args['usuario'],
                    'clave' => $this->args['clave'],
                ],
            ]);
            if ($xml['status']['code']!=200) {
                $this->log(' [error] Al obtener el XML '.$doc['codigo'].': '.$xml['body']);
            } else {
                file_put_contents($this->args['salida'].'/emitidos/dte_'.$this->args['contribuyente'].'_T'.$this->getCodigoDTE($doc['dte']).'F'.$doc['folio'].'.xml', $xml['body']);
            }
        }
    }
954345
protected function parseXML($xml) {
        if (!$xml || !$xml->Shipment){
            return false;
        }
        $d = $xml->Shipment;
        $this->data['ShipmentId'] = (string)$d->ShipmentId;
        $this->data['AmazonOrderId'] = (string)$d->AmazonOrderId;
        if (isset($d->SellerOrderId)) {
            $this->data['SellerOrderId'] = (string)$d->SellerOrderId;
        }
        $this->data['Status'] = (string)$d->Status;
        if (isset($d->TrackingId)) {
            $this->data['TrackingId'] = (string)$d->TrackingId;
        }
        $this->data['CreatedDate'] = (string)$d->CreatedDate;
        if (isset($d->LastUpdatedDate)) {
            $this->data['LastUpdatedDate'] = (string)$d->LastUpdatedDate;
        }
        $this->data['Weight']['Value'] = (string)$d->Weight->Value;
        $this->data['Weight']['Unit'] = (string)$d->Weight->Unit;
        $this->data['Insurance']['Amount'] = (string)$d->Insurance->Amount;
        $this->data['Insurance']['CurrencyCode'] = (string)$d->Insurance->CurrencyCode;
        if (isset($d->Label)) {
            $this->data['Label']['Dimensions']['Length'] = (string)$d->Label->Dimensions->Length;
            $this->data['Label']['Dimensions']['Width'] = (string)$d->Label->Dimensions->Width;
            $this->data['Label']['Dimensions']['Unit'] = (string)$d->Label->Dimensions->Unit;
            $this->data['Label']['FileContents']['Contents'] = (string)$d->Label->FileContents->Contents;
            $this->data['Label']['FileContents']['FileType'] = (string)$d->Label->FileContents->FileType;
            $this->data['Label']['FileContents']['Checksum'] = (string)$d->Label->FileContents->Checksum;
            if (isset($d->Label->CustomTextForLabel)) {
                $this->data['Label']['CustomTextForLabel'] = (string)$d->Label->CustomTextForLabel;
            }
            if (isset($d->Label->LabelFormat)) {
                $this->data['Label']['LabelFormat'] = (string)$d->Label->LabelFormat;
            }
            if (isset($d->Label->StandardIdForLabel)) {
                $this->data['Label']['StandardIdForLabel'] = (string)$d->Label->StandardIdForLabel;
            }
        }

        $this->data['ItemList'] = array();
        foreach ($d->ItemList->children() as $x) {
            $temp = array();
            $temp['OrderItemId'] = (string)$x->OrderItemId;
            $temp['Quantity'] = (string)$x->Quantity;
            $this->data['ItemList'][] = $temp;
        }
        if (isset($d->PackageDimensions->Length)) {
            $this->data['PackageDimensions']['Length'] = (string)$d->PackageDimensions->Length;
            $this->data['PackageDimensions']['Width'] = (string)$d->PackageDimensions->Width;
            $this->data['PackageDimensions']['Height'] = (string)$d->PackageDimensions->Height;
            $this->data['PackageDimensions']['Unit'] = (string)$d->PackageDimensions->Unit;
        }
        if (isset($d->PackageDimensions->PredefinedPackageDimensions)) {
            $this->data['PackageDimensions']['PredefinedPackageDimensions'] = (string)$d->PackageDimensions->PredefinedPackageDimensions;
        }

        //Ship From Address
        $this->data['ShipFromAddress']['Name'] = (string)$d->ShipFromAddress->Name;
        $this->data['ShipFromAddress']['AddressLine1'] = (string)$d->ShipFromAddress->AddressLine1;
        if (isset($d->ShipFromAddress->AddressLine3)) {
            $this->data['ShipFromAddress']['AddressLine2'] = (string)$d->ShipFromAddress->AddressLine2;
        }
        if (isset($d->ShipFromAddress->AddressLine3)) {
            $this->data['ShipFromAddress']['AddressLine2'] = (string)$d->ShipFromAddress->AddressLine3;
        }
        if (isset($d->ShipFromAddress->DistrictOrCounty)) {
            $this->data['ShipFromAddress']['DistrictOrCounty'] = (string)$d->ShipFromAddress->DistrictOrCounty;
        }
        $this->data['ShipFromAddress']['Email'] = (string)$d->ShipFromAddress->Email;
        $this->data['ShipFromAddress']['City'] = (string)$d->ShipFromAddress->City;
        if (isset($d->ShipFromAddress->StateOrProvinceCode)) {
            $this->data['ShipFromAddress']['StateOrProvinceCode'] = (string)$d->ShipFromAddress->StateOrProvinceCode;
        }
        $this->data['ShipFromAddress']['PostalCode'] = (string)$d->ShipFromAddress->PostalCode;
        $this->data['ShipFromAddress']['CountryCode'] = (string)$d->ShipFromAddress->CountryCode;
        $this->data['ShipFromAddress']['Phone'] = (string)$d->ShipFromAddress->Phone;

        //Ship To Address
        $this->data['ShipToAddress']['Name'] = (string)$d->ShipToAddress->Name;
        $this->data['ShipToAddress']['AddressLine1'] = (string)$d->ShipToAddress->AddressLine1;
        if (isset($d->ShipToAddress->AddressLine3)) {
            $this->data['ShipToAddress']['AddressLine2'] = (string)$d->ShipToAddress->AddressLine2;
        }
        if (isset($d->ShipToAddress->AddressLine3)) {
            $this->data['ShipToAddress']['AddressLine2'] = (string)$d->ShipToAddress->AddressLine3;
        }
        if (isset($d->ShipToAddress->DistrictOrCounty)) {
            $this->data['ShipToAddress']['DistrictOrCounty'] = (string)$d->ShipToAddress->DistrictOrCounty;
        }
        $this->data['ShipToAddress']['Email'] = (string)$d->ShipToAddress->Email;
        $this->data['ShipToAddress']['City'] = (string)$d->ShipToAddress->City;
        if (isset($d->ShipToAddress->StateOrProvinceCode)) {
            $this->data['ShipToAddress']['StateOrProvinceCode'] = (string)$d->ShipToAddress->StateOrProvinceCode;
        }
        $this->data['ShipToAddress']['PostalCode'] = (string)$d->ShipToAddress->PostalCode;
        $this->data['ShipToAddress']['CountryCode'] = (string)$d->ShipToAddress->CountryCode;
        $this->data['ShipToAddress']['Phone'] = (string)$d->ShipToAddress->Phone;

        //Service
        $this->data['ShippingService']['ShippingServiceName'] = (string)$d->ShippingService->ShippingServiceName;
        $this->data['ShippingService']['CarrierName'] = (string)$d->ShippingService->CarrierName;
        $this->data['ShippingService']['ShippingServiceId'] = (string)$d->ShippingService->ShippingServiceId;
        $this->data['ShippingService']['ShippingServiceOfferId'] = (string)$d->ShippingService->ShippingServiceOfferId;
        $this->data['ShippingService']['ShipDate'] = (string)$d->ShippingService->ShipDate;
        if (isset($d->ShippingService->EarliestEstimatedDeliveryDate)) {
            $this->data['ShippingService']['EarliestEstimatedDeliveryDate'] = (string)$d->ShippingService->EarliestEstimatedDeliveryDate;
        }
        if (isset($d->ShippingService->LatestEstimatedDeliveryDate)) {
            $this->data['ShippingService']['LatestEstimatedDeliveryDate'] = (string)$d->ShippingService->LatestEstimatedDeliveryDate;
        }
        $this->data['ShippingService']['Rate']['Amount'] = (string)$d->ShippingService->Rate->Amount;
        $this->data['ShippingService']['Rate']['CurrencyCode'] = (string)$d->ShippingService->Rate->CurrencyCode;
        $this->data['ShippingService']['DeliveryExperience'] = (string)$d->ShippingService->ShippingServiceOptions->DeliveryExperience;
        $this->data['ShippingService']['CarrierWillPickUp'] = (string)$d->ShippingService->ShippingServiceOptions->CarrierWillPickUp;
        if (isset($d->ShippingService->ShippingServiceOptions->DeclaredValue)) {
            $this->data['ShippingService']['DeclaredValue']['Amount'] = (string)$d->ShippingService->ShippingServiceOptions->DeclaredValue->Amount;
            $this->data['ShippingService']['DeclaredValue']['CurrencyCode'] = (string)$d->ShippingService->ShippingServiceOptions->DeclaredValue->CurrencyCode;
        }
    }