public function dispatch(Request $request, Response $response, $args)
 {
     $this->id = $args['id'];
     //        $this->logger->info("[" . $this->id . "] - Get data with the weather forecast");
     FileSystemCache::$cacheDir = './cache/tmp';
     $key = FileSystemCache::generateCacheKey('cache-feed-' . $this->id, null);
     $data = FileSystemCache::retrieve($key);
     if ($data === false) {
         $this->data_json = array('datetime' => json_decode(file_get_contents('http://dsx.weather.com/cs/v2/datetime/' . $this->locale . '/' . $args['id'] . ':1:BR'), true), 'now' => json_decode(file_get_contents('http://dsx.weather.com/wxd/v2/MORecord/' . $this->locale . '/' . $args['id'] . ':1:BR'), true), 'forecasts' => json_decode(file_get_contents('http://dsx.weather.com/wxd/v2/15DayForecast/' . $this->locale . '/' . $args['id'] . ':1:BR'), true));
         $data = array('info' => $this->processInfo(), 'now' => $this->processNow(), 'forecasts' => $this->processForecast());
         FileSystemCache::store($key, $data, 1800);
     } else {
         //            $this->logger->info("[" . $this->id . "] - Using cache to generate xml");
     }
     $xmlBuilder = new XmlBuilder('root');
     $xmlBuilder->setSingularizer(function ($name) {
         if ('forecasts' === $name) {
             return 'item';
         }
         return $name;
     });
     $xmlBuilder->load($data);
     $xml_output = $xmlBuilder->createXML(true);
     $response->write($xml_output);
     $response = $response->withHeader('content-type', 'text/xml');
     return $response;
 }
 /**
  * @return string
  */
 function GetXML()
 {
     require_once 'xml-processing/xmlbuilder.php';
     $xml_data = new XmlBuilder();
     $xml_data->Push('merchant-calculation-results', array('xmlns' => $this->schema_url));
     $xml_data->Push('results');
     foreach ($this->results_arr as $result) {
         if ($result->shipping_name != "") {
             $xml_data->Push('result', array('shipping-name' => $result->shipping_name, 'address-id' => $result->address_id));
             $xml_data->Element('shipping-rate', $result->ship_price, array('currency' => $result->ship_currency));
             $xml_data->Element('shippable', $result->shippable);
         } else {
             $xml_data->Push('result', array('address-id' => $result->address_id));
         }
         if ($result->tax_amount != "") {
             $xml_data->Element('total-tax', $result->tax_amount, array('currency' => $result->tax_currency));
         }
         if (count($result->coupon_arr) != 0 || count($result->giftcert_arr) != 0) {
             $xml_data->Push('merchant-code-results');
             foreach ($result->coupon_arr as $curr_coupon) {
                 $xml_data->Push('coupon-result');
                 $xml_data->Element('valid', $curr_coupon->coupon_valid);
                 $xml_data->Element('code', $curr_coupon->coupon_code);
                 $xml_data->Element('calculated-amount', $curr_coupon->coupon_amount, array('currency' => $curr_coupon->coupon_currency));
                 $xml_data->Element('message', $curr_coupon->coupon_message);
                 $xml_data->Pop('coupon-result');
             }
             foreach ($result->giftcert_arr as $curr_gift) {
                 $xml_data->Push('gift-result');
                 $xml_data->Element('valid', $curr_gift->gift_valid);
                 $xml_data->Element('code', $curr_gift->gift_code);
                 $xml_data->Element('calculated-amount', $curr_gift->gift_amount, array('currency' => $curr_gift->gift_currency));
                 $xml_data->Element('message', $curr_gift->gift_message);
                 $xml_data->Pop('gift-result');
             }
             $xml_data->Pop('merchant-code-results');
         }
         $xml_data->Pop('result');
     }
     $xml_data->Pop('results');
     $xml_data->Pop('merchant-calculation-results');
     return $xml_data->GetXML();
 }
示例#3
0
 function GetXML()
 {
     require_once 'xml-processing/xmlbuilder.php';
     $xml_data = new XmlBuilder();
     $xml_data->Push('checkout-shopping-cart', array('xmlns' => $this->schema_url));
     $xml_data->Push('shopping-cart');
     //Add cart expiration if set
     if ($this->cart_expiration != "") {
         $xml_data->Push('cart-expiration');
         $xml_data->Element('good-until-date', $this->cart_expiration);
         $xml_data->Pop('cart-expiration');
     }
     //Add XML data for each of the items
     $xml_data->Push('items');
     foreach ($this->item_arr as $item) {
         $xml_data->Push('item');
         $xml_data->Element('item-name', $item->item_name);
         $xml_data->Element('item-description', $item->item_description);
         $xml_data->Element('unit-price', $item->unit_price, array('currency' => $item->currency));
         $xml_data->Element('quantity', $item->quantity);
         if ($item->merchant_private_data != '') {
             $xml_data->Element('merchant-private-date', $item->merchant_private_data);
         }
         if ($item->tax_table_selector != '') {
             $xml_data->Element('tax-table-selector', $item->tax_table_selector);
         }
         $xml_data->Pop('item');
     }
     $xml_data->Pop('items');
     if ($this->merchant_private_data != '') {
         $xml_data->Element('merchant-private-data', $this->merchant_private_data);
     }
     $xml_data->Pop('shopping-cart');
     $xml_data->Push('checkout-flow-support');
     $xml_data->Push('merchant-checkout-flow-support');
     if ($this->edit_cart_url != '') {
         $xml_data->Element('edit-cart-url', $this->edit_cart_url);
     }
     if ($this->continue_shopping_url != '') {
         $xml_data->Element('continue-shopping-url', $this->continue_shopping_url);
     }
     if (count($this->shipping_arr) > 0) {
         $xml_data->Push('shipping-methods');
     }
     //Add the shipping methods
     foreach ($this->shipping_arr as $ship) {
         //Pickup shipping handled in else part
         if ($ship->type == "flat-rate" || $ship->type == "merchant-calculated") {
             $xml_data->Push($ship->type . '-shipping', array('name' => $ship->name));
             $xml_data->Element('price', $ship->price, array('currency' => $ship->currency));
             //Check if shipping restrictions have been specifd=ied
             if ($ship->allowed_restrictions || $ship->excluded_restrictions) {
                 $xml_data->Push('shipping-restrictions');
                 //Check if allowed restrictions specified
                 if ($ship->allowed_restrictions) {
                     $xml_data->Push('allowed-areas');
                     if ($ship->allowed_country_area != "") {
                         $xml_data->Element('us-country-area', '', array('country-area' => $ship->allowed_country_area));
                     }
                     foreach ($ship->allowed_state_areas_arr as $current) {
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                     }
                     foreach ($ship->allowed_zip_patterns_arr as $current) {
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                     }
                     $xml_data->Pop('allowed-areas');
                 }
                 if ($ship->excluded_restrictions) {
                     $xml_data->Push('allowed-areas');
                     $xml_data->Pop('allowed-areas');
                     $xml_data->Push('excluded-areas');
                     if ($ship->excluded_country_area != "") {
                         $xml_data->Element('us-country-area', '', array('country-area' => $ship->excluded_country_area));
                     }
                     foreach ($ship->excluded_state_areas_arr as $current) {
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                     }
                     foreach ($ship->excluded_zip_patterns_arr as $current) {
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                     }
                     $xml_data->Pop('excluded-areas');
                 }
                 $xml_data->Pop('shipping-restrictions');
             }
             $xml_data->Pop($ship->type . '-shipping');
         } else {
             if ($ship->type == "pickup") {
                 $xml_data->Push('pickup', array('name' => $ship->name));
                 $xml_data->Element('price', $ship->price, array('currency' => $ship->currency));
                 $xml_data->Pop('pickup');
             }
         }
     }
     if (count($this->shipping_arr) > 0) {
         $xml_data->Pop('shipping-methods');
     }
     if ($this->request_buyer_phone != "") {
         $xml_data->Element('request-buyer-phone-number', $this->request_buyer_phone);
     }
     if ($this->merchant_calculations_url != "") {
         $xml_data->Push('merchant-calculations');
         $xml_data->Element('merchant-calculations-url', $this->merchant_calculations_url);
         if ($this->accept_merchant_coupons != "") {
             $xml_data->Element('accept-merchant-coupons', $this->accept_merchant_coupons);
         }
         if ($this->accept_gift_certificates != "") {
             $xml_data->Element('accept-gift-certificates', $this->accept_gift_certificates);
         }
         $xml_data->Pop('merchant-calculations');
     }
     //Set Default and Alternate tax tables
     if (count($this->alternate_tax_table_arr) != 0 || isset($this->default_tax_table)) {
         if ($this->merchant_calculated != "") {
             $xml_data->Push('tax-tables', array('merchant-calculated' => $this->merchant_calculated));
         } else {
             $xml_data->Push('tax-tables');
         }
         if (isset($this->default_tax_table)) {
             $curr_table = $this->default_tax_table;
             foreach ($curr_table->tax_rules_arr as $curr_rule) {
                 $xml_data->Push('default-tax-table');
                 $xml_data->Push('tax-rules');
                 foreach ($curr_rule->state_areas_arr as $current) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     if ($curr_rule->country_area != "") {
                         $xml_data->Element('us-country-area', '', array('country-area' => $curr_rule->country_area));
                     }
                     $xml_data->Push('us-state-area');
                     $xml_data->Element('state', $current);
                     $xml_data->Pop('us-state-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 foreach ($curr_rule->zip_patterns_arr as $current) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     if ($curr_rule->country_area != "") {
                         $xml_data->Element('us-country-area', '', array('country-area' => $curr_rule->country_area));
                     }
                     $xml_data->Push('us-zip-area');
                     $xml_data->Element('zip-pattern', $current);
                     $xml_data->Pop('us-zip-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 $xml_data->Pop('tax-rules');
                 $xml_data->Pop('default-tax-table');
             }
         }
         if (count($this->alternate_tax_table_arr) != 0) {
             $xml_data->Push('alternate-tax-tables');
             foreach ($this->alternate_tax_table_arr as $curr_table) {
                 foreach ($curr_table->tax_rules_arr as $curr_rule) {
                     $xml_data->Push('alternate-tax-table', array('standalone' => $curr_table->standalone, 'name' => $curr_table->name));
                     $xml_data->Push('alternate-tax-rules');
                     foreach ($curr_rule->state_areas_arr as $current) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         if ($curr_rule->country_area != "") {
                             $xml_data->Element('us-country-area', '', array('country-area' => $curr_rule->country_area));
                         }
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     foreach ($curr_rule->zip_patterns_arr as $current) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         if ($curr_rule->country_area != "") {
                             $xml_data->Element('us-country-area', '', array('country-area' => $curr_rule->country_area));
                         }
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     $xml_data->Pop('alternate-tax-rules');
                     $xml_data->Pop('alternate-tax-table');
                 }
             }
             $xml_data->Pop('alternate-tax-tables');
         }
         $xml_data->Pop('tax-tables');
     }
     $xml_data->Pop('merchant-checkout-flow-support');
     $xml_data->Pop('checkout-flow-support');
     $xml_data->Pop('checkout-shopping-cart');
     return $xml_data->GetXML();
 }
 /**
  * @return string The rendered xml for this batch.
  */
 function getXml()
 {
     $xml = new XmlBuilder();
     $feed_attrs = array('xmlns' => 'http://www.w3.org/2005/Atom', 'xmlns:openSearch' => 'http://a9.com/-/spec/opensearchrss/1.0/', 'xmlns:g' => 'http://base.google.com/ns/1.0', 'xmlns:batch' => 'http://schemas.google.com/gdata/batch');
     $xml->Push('feed', $feed_attrs);
     $this->_title->addToXml($xml);
     foreach ($this->_insert as $id => $item) {
         $item->addAttribute(new GoogleBaseBatchAttribute('id', $id));
         $item->addAttribute(new GoogleBaseBatchAttribute('operation', '', 'insert'));
         $xml->Append($item->getXml($batch = true));
     }
     foreach ($this->_delete as $id => $item) {
         $item->addAttribute(new GoogleBaseBatchAttribute('operation', '', 'delete'));
         $xml->Append($item->getXml($batch = true));
     }
     foreach ($this->_update as $id => $item) {
         $item->addAttribute(new GoogleBaseBatchAttribute('operation', '', 'update'));
         $xml->Append($item->getXml($batch = true));
     }
     $xml->Pop('feed');
     return $xml->GetXML();
 }
示例#5
0
$query = "SELECT COUNT(`id`) AS `points_widgets`, DATE_FORMAT(`date_premium`, '{$dateFormatSQL}') as `ord_date` FROM `quizzes`\n\t\tWHERE  DATE_FORMAT(`date_premium`, '%Y-%m-%d') >= '{$_POST['date_from']}' \n\t\tAND DATE_FORMAT(`date_premium`, '%Y-%m-%d') <= '{$_POST['date_to']}' AND `flags` & " . Quiz::FLAG_PREMIUM . "  AND  `premium_type` = 'points'  \n\t\tGROUP BY `ord_date` ";
$db = new DbMySql($query);
while ($db->nextRecord()) {
    $fieldValue = $db->f('points_widgets');
    $resWidgets[$db->f('ord_date')]['points_widgets'] = isset($resWidgets[$db->f('ord_date')]['points_widgets']) ? $resWidgets[$db->f('ord_date')]['points_widgets'] + $fieldValue : $fieldValue;
    $resWidgets[$db->f('ord_date')]['total_widgets'] = isset($resWidgets[$db->f('ord_date')]['total_widgets']) ? $resWidgets[$db->f('ord_date')]['total_widgets'] + $fieldValue : $fieldValue;
}
#vip
$query = "SELECT COUNT(`id`) AS `vip_widgets`, DATE_FORMAT(`date_premium`, '{$dateFormatSQL}') as `ord_date` FROM `quizzes`\n\t\tWHERE  DATE_FORMAT(`date_premium`, '%Y-%m-%d') >= '{$_POST['date_from']}' \n\t\tAND DATE_FORMAT(`date_premium`, '%Y-%m-%d') <= '{$_POST['date_to']}' AND  `flags` & " . Quiz::FLAG_PREMIUM . "  AND  `premium_type` = 'subscription'  \n\t\tGROUP BY `ord_date` ";
$db = new DbMySql($query);
while ($db->nextRecord()) {
    $fieldValue = $db->f('vip_widgets');
    $resWidgets[$db->f('ord_date')]['vip_widgets'] = isset($resWidgets[$db->f('ord_date')]['vip_widgets']) ? $resWidgets[$db->f('ord_date')]['vip_widgets'] + $fieldValue : $fieldValue;
    $resWidgets[$db->f('ord_date')]['total_widgets'] = isset($resWidgets[$db->f('ord_date')]['total_widgets']) ? $resWidgets[$db->f('ord_date')]['total_widgets'] + $fieldValue : $fieldValue;
}
$xml = new XmlBuilder();
$xml->Push('response');
$xml->Element('code', 200);
$xml->Element('status', ServMessages::getMessage(20));
foreach ($resPoints as $date => $result) {
    $xml->Push('results_points');
    $xml->Element('date', $date);
    $xml->Element('used_points', isset($result['used_points']) ? $result['used_points'] : 0);
    $xml->Element('vip_used_points', isset($result['vip_used_points']) ? $result['vip_used_points'] : 0);
    $xml->Element('total_used_points', isset($result['total_used_points']) ? $result['total_used_points'] : 0);
    $xml->Pop('results_points');
}
foreach ($resWidgets as $date => $result) {
    $xml->Push('results_widgets');
    $xml->Element('date', $date);
    $xml->Element('vip_widgets', isset($result['vip_widgets']) ? $result['vip_widgets'] : 0);
 function GetXML()
 {
     require_once 'xml-processing/xmlbuilder.php';
     $xml_data = new XmlBuilder();
     $xml_data->Push('checkout-shopping-cart', array('xmlns' => $this->schema_url));
     $xml_data->Push('shopping-cart');
     //Add cart expiration if set
     if ($this->cart_expiration != "") {
         $xml_data->Push('cart-expiration');
         $xml_data->Element('good-until-date', $this->cart_expiration);
         $xml_data->Pop('cart-expiration');
     }
     //Add XML data for each of the items
     $xml_data->Push('items');
     foreach ($this->item_arr as $item) {
         $xml_data->Push('item');
         $xml_data->Element('item-name', $item->item_name);
         $xml_data->Element('item-description', $item->item_description);
         $xml_data->Element('unit-price', $item->unit_price, array('currency' => $this->currency));
         $xml_data->Element('quantity', $item->quantity);
         if ($item->merchant_private_item_data != '') {
             $xml_data->Element('merchant-private-item-data', $item->merchant_private_item_data);
         }
         if ($item->merchant_item_id != '') {
             $xml_data->Element('merchant-item-id', $item->merchant_item_id);
         }
         if ($item->tax_table_selector != '') {
             $xml_data->Element('tax-table-selector', $item->tax_table_selector);
         }
         $xml_data->Pop('item');
     }
     $xml_data->Pop('items');
     if ($this->merchant_private_data != '') {
         $xml_data->Element('merchant-private-data', $this->merchant_private_data);
     }
     $xml_data->Pop('shopping-cart');
     $xml_data->Push('checkout-flow-support');
     $xml_data->Push('merchant-checkout-flow-support');
     if ($this->edit_cart_url != '') {
         $xml_data->Element('edit-cart-url', $this->edit_cart_url);
     }
     if ($this->continue_shopping_url != '') {
         $xml_data->Element('continue-shopping-url', $this->continue_shopping_url);
     }
     if (count($this->shipping_arr) > 0) {
         $xml_data->Push('shipping-methods');
     }
     //Add the shipping methods
     foreach ($this->shipping_arr as $ship) {
         //Pickup shipping handled in else part
         if ($ship->type == "flat-rate-shipping" || $ship->type == "merchant-calculated-shipping") {
             $xml_data->Push($ship->type, array('name' => $ship->name));
             $xml_data->Element('price', $ship->price, array('currency' => $this->currency));
             $shipping_restrictions = $ship->shipping_restrictions;
             if (isset($shipping_restrictions)) {
                 $xml_data->Push('shipping-restrictions');
                 if ($shipping_restrictions->allow_us_po_box === true) {
                     $xml_data->Element('allow-us-po-box', "true");
                 } else {
                     $xml_data->Element('allow-us-po-box', "false");
                 }
                 //Check if allowed restrictions specified
                 if ($shipping_restrictions->allowed_restrictions) {
                     $xml_data->Push('allowed-areas');
                     if ($shipping_restrictions->allowed_country_area != "") {
                         $xml_data->Element('us-country-area', '', array('country-area' => $shipping_restrictions->allowed_country_area));
                     }
                     foreach ($shipping_restrictions->allowed_state_areas_arr as $current) {
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                     }
                     foreach ($shipping_restrictions->allowed_zip_patterns_arr as $current) {
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                     }
                     if ($shipping_restrictions->allowed_world_area === true) {
                         $xml_data->EmptyElement('world-area');
                     }
                     for ($i = 0; $i < count($shipping_restrictions->allowed_country_codes_arr); $i++) {
                         $xml_data->Push('postal-area');
                         $country_code = $shipping_restrictions->allowed_country_codes_arr[$i];
                         $postal_pattern = $shipping_restrictions->allowed_postal_patterns_arr[$i];
                         $xml_data->Element('country-code', $country_code);
                         if ($postal_pattern != "") {
                             $xml_data->Element('postal-code-pattern', $postal_pattern);
                         }
                         $xml_data->Pop('postal-area');
                     }
                     $xml_data->Pop('allowed-areas');
                 }
                 if ($shipping_restrictions->excluded_restrictions) {
                     if (!$shipping_restrictions->allowed_restrictions) {
                         $xml_data->EmptyElement('allowed-areas');
                     }
                     $xml_data->Push('excluded-areas');
                     if ($shipping_restrictions->excluded_country_area != "") {
                         $xml_data->Element('us-country-area', '', array('country-area' => $shipping_restrictions->excluded_country_area));
                     }
                     foreach ($shipping_restrictions->excluded_state_areas_arr as $current) {
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                     }
                     foreach ($shipping_restrictions->excluded_zip_patterns_arr as $current) {
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                     }
                     for ($i = 0; $i < count($shipping_restrictions->excluded_country_codes_arr); $i++) {
                         $xml_data->Push('postal-area');
                         $country_code = $shipping_restrictions->excluded_country_codes_arr[$i];
                         $postal_pattern = $shipping_restrictions->excluded_postal_patterns_arr[$i];
                         $xml_data->Element('country-code', $country_code);
                         if ($postal_pattern != "") {
                             $xml_data->Element('postal-code-pattern', $postal_pattern);
                         }
                         $xml_data->Pop('postal-area');
                     }
                     $xml_data->Pop('excluded-areas');
                 }
                 $xml_data->Pop('shipping-restrictions');
             }
             if ($ship->type == "merchant-calculated-shipping") {
                 $address_filters = $ship->address_filters;
                 if (isset($address_filters)) {
                     $xml_data->Push('address-filters');
                     if ($address_filters->allow_us_po_box === true) {
                         $xml_data->Element('allow-us-po-box', "true");
                     } else {
                         $xml_data->Element('allow-us-po-box', "false");
                     }
                     //Check if allowed restrictions specified
                     if ($address_filters->allowed_restrictions) {
                         $xml_data->Push('allowed-areas');
                         if ($address_filters->allowed_country_area != "") {
                             $xml_data->Element('us-country-area', '', array('country-area' => $address_filters->allowed_country_area));
                         }
                         foreach ($address_filters->allowed_state_areas_arr as $current) {
                             $xml_data->Push('us-state-area');
                             $xml_data->Element('state', $current);
                             $xml_data->Pop('us-state-area');
                         }
                         foreach ($address_filters->allowed_zip_patterns_arr as $current) {
                             $xml_data->Push('us-zip-area');
                             $xml_data->Element('zip-pattern', $current);
                             $xml_data->Pop('us-zip-area');
                         }
                         if ($address_filters->allowed_world_area === true) {
                             $xml_data->EmptyElement('world-area');
                         }
                         for ($i = 0; $i < count($address_filters->allowed_country_codes_arr); $i++) {
                             $xml_data->Push('postal-area');
                             $country_code = $address_filters->allowed_country_codes_arr[$i];
                             $postal_pattern = $address_filters->allowed_postal_patterns_arr[$i];
                             $xml_data->Element('country-code', $country_code);
                             if ($postal_pattern != "") {
                                 $xml_data->Element('postal-code-pattern', $postal_pattern);
                             }
                             $xml_data->Pop('postal-area');
                         }
                         $xml_data->Pop('allowed-areas');
                     }
                     if ($address_filters->excluded_restrictions) {
                         if (!$address_filters->allowed_restrictions) {
                             $xml_data->EmptyElement('allowed-areas');
                         }
                         $xml_data->Push('excluded-areas');
                         if ($address_filters->excluded_country_area != "") {
                             $xml_data->Element('us-country-area', '', array('country-area' => $address_filters->excluded_country_area));
                         }
                         foreach ($address_filters->excluded_state_areas_arr as $current) {
                             $xml_data->Push('us-state-area');
                             $xml_data->Element('state', $current);
                             $xml_data->Pop('us-state-area');
                         }
                         foreach ($address_filters->excluded_zip_patterns_arr as $current) {
                             $xml_data->Push('us-zip-area');
                             $xml_data->Element('zip-pattern', $current);
                             $xml_data->Pop('us-zip-area');
                         }
                         for ($i = 0; $i < count($address_filters->excluded_country_codes_arr); $i++) {
                             $xml_data->Push('postal-area');
                             $country_code = $address_filters->excluded_country_codes_arr[$i];
                             $postal_pattern = $address_filters->excluded_postal_patterns_arr[$i];
                             $xml_data->Element('country-code', $country_code);
                             if ($postal_pattern != "") {
                                 $xml_data->Element('postal-code-pattern', $postal_pattern);
                             }
                             $xml_data->Pop('postal-area');
                         }
                         $xml_data->Pop('excluded-areas');
                     }
                     $xml_data->Pop('address-filters');
                 }
             }
             $xml_data->Pop($ship->type);
         } else {
             if ($ship->type == "pickup") {
                 $xml_data->Push('pickup', array('name' => $ship->name));
                 $xml_data->Element('price', $ship->price, array('currency' => $this->currency));
                 $xml_data->Pop('pickup');
             }
         }
     }
     if (count($this->shipping_arr) > 0) {
         $xml_data->Pop('shipping-methods');
     }
     if ($this->request_buyer_phone != "") {
         $xml_data->Element('request-buyer-phone-number', $this->request_buyer_phone);
     }
     if ($this->merchant_calculations_url != "") {
         $xml_data->Push('merchant-calculations');
         $xml_data->Element('merchant-calculations-url', $this->merchant_calculations_url);
         if ($this->accept_merchant_coupons != "") {
             $xml_data->Element('accept-merchant-coupons', $this->accept_merchant_coupons);
         }
         if ($this->accept_gift_certificates != "") {
             $xml_data->Element('accept-gift-certificates', $this->accept_gift_certificates);
         }
         $xml_data->Pop('merchant-calculations');
     }
     //Set Default and Alternate tax tables
     if (count($this->alternate_tax_tables_arr) != 0 || count($this->default_tax_rules_arr) != 0) {
         if ($this->merchant_calculated != "") {
             $xml_data->Push('tax-tables', array('merchant-calculated' => $this->merchant_calculated));
         } else {
             $xml_data->Push('tax-tables');
         }
         if (count($this->default_tax_rules_arr) != 0) {
             $xml_data->Push('default-tax-table');
             $xml_data->Push('tax-rules');
             foreach ($this->default_tax_rules_arr as $curr_rule) {
                 if ($curr_rule->country_area != "") {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->Element('us-country-area', '', array('country-area' => $curr_rule->country_area));
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 foreach ($curr_rule->state_areas_arr as $current) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->Push('us-state-area');
                     $xml_data->Element('state', $current);
                     $xml_data->Pop('us-state-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 foreach ($curr_rule->zip_patterns_arr as $current) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->Push('us-zip-area');
                     $xml_data->Element('zip-pattern', $current);
                     $xml_data->Pop('us-zip-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 for ($i = 0; $i < count($curr_rule->country_codes_arr); $i++) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->Push('postal-area');
                     $country_code = $curr_rule->country_codes_arr[$i];
                     $postal_pattern = $curr_rule->postal_patterns_arr[$i];
                     $xml_data->Element('country-code', $country_code);
                     if ($postal_pattern != "") {
                         $xml_data->Element('postal-code-pattern', $postal_pattern);
                     }
                     $xml_data->Pop('postal-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
                 if ($curr_rule->world_area === true) {
                     $xml_data->Push('default-tax-rule');
                     $xml_data->Element('shipping-taxed', $curr_rule->shipping_taxed);
                     $xml_data->Element('rate', $curr_rule->tax_rate);
                     $xml_data->Push('tax-area');
                     $xml_data->EmptyElement('world-area');
                     $xml_data->Pop('tax-area');
                     $xml_data->Pop('default-tax-rule');
                 }
             }
             $xml_data->Pop('tax-rules');
             $xml_data->Pop('default-tax-table');
         }
         if (count($this->alternate_tax_tables_arr) != 0) {
             $xml_data->Push('alternate-tax-tables');
             foreach ($this->alternate_tax_tables_arr as $curr_table) {
                 $xml_data->Push('alternate-tax-table', array('standalone' => $curr_table->standalone, 'name' => $curr_table->name));
                 $xml_data->Push('alternate-tax-rules');
                 foreach ($curr_table->tax_rules_arr as $curr_rule) {
                     if ($curr_rule->country_area != "") {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->Element('us-country-area', '', array('country-area' => $curr_rule->country_area));
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     foreach ($curr_rule->state_areas_arr as $current) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->Push('us-state-area');
                         $xml_data->Element('state', $current);
                         $xml_data->Pop('us-state-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     foreach ($curr_rule->zip_patterns_arr as $current) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->Push('us-zip-area');
                         $xml_data->Element('zip-pattern', $current);
                         $xml_data->Pop('us-zip-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     for ($i = 0; $i < count($curr_rule->country_codes_arr); $i++) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->Push('postal-area');
                         $country_code = $curr_rule->country_codes_arr[$i];
                         $postal_pattern = $curr_rule->postal_patterns_arr[$i];
                         $xml_data->Element('country-code', $country_code);
                         if ($postal_pattern != "") {
                             $xml_data->Element('postal-code-pattern', $postal_pattern);
                         }
                         $xml_data->Pop('postal-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                     if ($curr_rule->world_area === true) {
                         $xml_data->Push('alternate-tax-rule');
                         $xml_data->Element('rate', $curr_rule->tax_rate);
                         $xml_data->Push('tax-area');
                         $xml_data->EmptyElement('world-area');
                         $xml_data->Pop('tax-area');
                         $xml_data->Pop('alternate-tax-rule');
                     }
                 }
                 $xml_data->Pop('alternate-tax-rules');
                 $xml_data->Pop('alternate-tax-table');
             }
             $xml_data->Pop('alternate-tax-tables');
         }
         $xml_data->Pop('tax-tables');
     }
     if ($this->rounding_mode != "" && $this->rounding_rule != "") {
         $xml_data->Push('rounding-policy');
         $xml_data->Element('mode', $this->rounding_mode);
         $xml_data->Element('rule', $this->rounding_rule);
         $xml_data->Pop('rounding-policy');
     }
     $xml_data->Pop('merchant-checkout-flow-support');
     $xml_data->Pop('checkout-flow-support');
     $xml_data->Pop('checkout-shopping-cart');
     return $xml_data->GetXML();
 }
示例#7
0
 public function test()
 {
     $v1 = XmlBuilder::general_error(50, "hello");
     $p1 = simplexml_load_string($v1);
     $this->assertTrue(!empty($p1->xpath("/response")), "[XmlBuilder::general_error()]");
     $this->assertTrue(!empty($p1->xpath("/response/error")), "[XmlBuilder::general_error()]");
     $this->assertTrue(!empty($p1->xpath("/response/error/code")), "[XmlBuilder::general_error()]");
     $this->assertTrue(!empty($p1->xpath("/response/error/message")), "[XmlBuilder::general_error()]");
     $this->assertEquals("50", $p1->error->code, "[XmlBuilder::general_error()]");
     $this->assertEquals("hello", $p1->error->message, "[XmlBuilder::general_error()]");
     $v2 = XmlBuilder::failed_response("plain", "1", "200", "bla");
     $p2 = simplexml_load_string($v2);
     $this->assertTrue(!empty($p2->xpath("/response")), "[XmlBuilder::failed_response()]");
     $this->assertTrue(!empty($p2->xpath("/response/header")), "[XmlBuilder::failed_response()]");
     $this->assertTrue(!empty($p2->xpath("/response/header/version")), "[XmlBuilder::failed_response()]");
     $this->assertEquals("1", $p2->header->version, "[XmlBuilder::failed_response()]");
     $this->assertEquals("plain", $p2->header['mode'], "[XmlBuilder::failed_response()]");
     $this->assertTrue(!empty($p2->xpath("/response/body")), "[XmlBuilder::failed_response()]");
     $this->assertTrue(!empty($p2->xpath("/response/body/id")), "[XmlBuilder::failed_response()]");
     $this->assertEquals("1", $p2->body->id, "[XmlBuilder::failed_response()]");
     $this->assertTrue(!empty($p2->xpath("/response/body/status")), "[XmlBuilder::failed_response()]");
     $this->assertEquals("failed", $p2->body->status, "[XmlBuilder::failed_response()]");
     $this->assertTrue(!empty($p2->xpath("/response/body/error_code")), "[XmlBuilder::failed_response()]");
     $this->assertEquals("200", $p2->body->error_code, "[XmlBuilder::failed_response()]");
     $this->assertTrue(!empty($p2->xpath("/response/body/reason")), "[XmlBuilder::failed_response()]");
     $this->assertEquals("bla", $p2->body->reason, "[XmlBuilder::failed_response()]");
     //registerNewUserSuccessfullResponse($mode)
     $v3 = XmlBuilder::registerNewUserSuccessfullResponse("plain");
     $p3 = simplexml_load_string($v3);
     $this->assertTrue(!empty($p3->xpath("/response")), "[XmlBuilder::registerNewUserSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/header/version")), "[XmlBuilder::registerNewUserSuccessfullResponse()]");
     $this->assertEquals("1", $p3->header->version, "[XmlBuilder::registerNewUserSuccessfullResponse()]");
     $this->assertEquals("plain", $p3->header['mode'], "[XmlBuilder::registerNewUserSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body")), "[XmlBuilder::registerNewUserSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/id")), "[XmlBuilder::registerNewUserSuccessfullResponse()]");
     $this->assertEquals("1", $p3->body->id, "[XmlBuilder::registerNewUserSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/status")), "[XmlBuilder::registerNewUserSuccessfullResponse()]");
     $this->assertEquals("successful", $p3->body->status, "[XmlBuilder::registerNewUserSuccessfullResponse()]");
     //newSessionSuccessfullResponse($mode,$hash)
     $hash = "whatever";
     $v3 = XmlBuilder::newSessionSuccessfullResponse("plain", $hash);
     $p3 = simplexml_load_string($v3);
     $this->assertTrue(!empty($p3->xpath("/response")), "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/header/version")), "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertEquals("1", $p3->header->version, "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertEquals("plain", $p3->header['mode'], "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body")), "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/id")), "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertEquals("2", $p3->body->id, "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/status")), "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertEquals("successful", $p3->body->status, "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/session")), "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertEquals($hash, $p3->body->session, "[XmlBuilder::newSessionSuccessfullResponse()]");
     //newSessionSuccessfullResponse($mode,$hash)
     $hash = "whatever";
     $v3 = XmlBuilder::endSessionSuccessfullResponse("plain", $hash);
     $p3 = simplexml_load_string($v3);
     $this->assertTrue(!empty($p3->xpath("/response")), "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/header/version")), "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertEquals("1", $p3->header->version, "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertEquals("plain", $p3->header['mode'], "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body")), "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/id")), "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertEquals("3", $p3->body->id, "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/status")), "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertEquals("successful", $p3->body->status, "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/session")), "[XmlBuilder::newSessionSuccessfullResponse()]");
     $this->assertEquals($hash, $p3->body->session, "[XmlBuilder::newSessionSuccessfullResponse()]");
     //registerGCMSuccessfullResponse($mode,$session)
     $hash = "whatever";
     $v3 = XmlBuilder::registerGCMSuccessfullResponse("plain", $hash);
     $p3 = simplexml_load_string($v3);
     $this->assertTrue(!empty($p3->xpath("/response")), "[XmlBuilder::registerGCMSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/header/version")), "[XmlBuilder::registerGCMSuccessfullResponse()]");
     $this->assertEquals("1", $p3->header->version, "[XmlBuilder::registerGCMSuccessfullResponse()]");
     $this->assertEquals("plain", $p3->header['mode'], "[XmlBuilder::registerGCMSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body")), "[XmlBuilder::registerGCMSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/id")), "[XmlBuilder::registerGCMSuccessfullResponse()]");
     $this->assertEquals("4", $p3->body->id, "[XmlBuilder::registerGCMSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/status")), "[XmlBuilder::registerGCMSuccessfullResponse()]");
     $this->assertEquals("successful", $p3->body->status, "[XmlBuilder::registerGCMSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/session")), "[XmlBuilder::registerGCMSuccessfullResponse()]");
     $this->assertEquals($hash, $p3->body->session, "[XmlBuilder::registerGCMSuccessfullResponse()]");
     //startNewPendingGameSuccessfullResponse($mode,$session)
     $hash = "whatever";
     $v3 = XmlBuilder::startNewPendingGameSuccessfullResponse("plain", $hash);
     $p3 = simplexml_load_string($v3);
     $this->assertTrue(!empty($p3->xpath("/response")), "[XmlBuilder::startNewPendingGameSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/header/version")), "[XmlBuilder::startNewPendingGameSuccessfullResponse()]");
     $this->assertEquals("1", $p3->header->version, "[XmlBuilder::startNewPendingGameSuccessfullResponse()]");
     $this->assertEquals("plain", $p3->header['mode'], "[XmlBuilder::startNewPendingGameSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body")), "[XmlBuilder::startNewPendingGameSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/id")), "[XmlBuilder::startNewPendingGameSuccessfullResponse()]");
     $this->assertEquals("5", $p3->body->id, "[XmlBuilder::startNewPendingGameSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/status")), "[XmlBuilder::startNewPendingGameSuccessfullResponse()]");
     $this->assertEquals("successful", $p3->body->status, "[XmlBuilder::startNewPendingGameSuccessfullResponse()]");
     $this->assertTrue(!empty($p3->xpath("/response/body/session")), "[XmlBuilder::startNewPendingGameSuccessfullResponse()]");
     $this->assertEquals($hash, $p3->body->session, "[XmlBuilder::startNewPendingGameSuccessfullResponse()]");
 }
示例#8
0
 public function startNewGame()
 {
     if (XmlRequestValidator::isValidStartPendingGameRequest($this->requestData)) {
         $session = $this->requestData->body->session;
         $size = $this->requestData->body->size;
         if (safe_input::is_valid_session_hash($session) && safe_input::is_number($size) && $size > 1) {
             //chkec if the session hash exists
             $session_info = session::get_session_by_hash($session);
             if ($session_info != null) {
                 $res = Execute::newPendingGame($session, $size);
                 if ($res) {
                     $this->response = XmlBuilder::startNewPendingGameSuccessfullResponse("plain", $session);
                 } else {
                     //faild to add new game
                     Report::error(__METHOD__ . "," . __LINE__, "failed to add new pending game");
                     $this->response = XmlBuilder::failed_response("plain", 5, 0, "failed to add new pending game, try again");
                 }
             } else {
                 //the given hash doesn't exist in the database
                 Report::warning(__METHOD__ . "," . __LINE__, "start new pending game request contains a session hash that does not exist in the database: hash=" . $session);
                 $this->response = XmlBuilder::failed_response("plain", 5, 1, "expired session");
             }
         } else {
             //invalid data passed
             Report::error(__METHOD__ . "," . __LINE__, "start new pending game request contains an incorrectly formatted session hash or game size, size:" . $size);
             $this->response = XmlBuilder::failed_response("plain", 5, 0, "invalid session or gcm id");
         }
     } else {
         //xml request was not formatted correctly
         Report::error(__METHOD__ . "," . __LINE__, "invalid new pending game request!");
         $this->invalidRequest();
     }
 }
示例#9
0
<?php

require_once './Builder.php';
require_once './TextBuilder.php';
require_once './XmlBuilder.php';
require_once './Director.php';
$header = "title->test";
$body = "test builder";
$footer = "end";
$text_builder = new TextBuilder();
$text_director = new Director($text_builder);
$text_director->construct($header, $body, $footer);
$xml_builder = new XmlBuilder();
$xml_director = new Director($xml_builder);
$xml_director->construct($header, $body, $footer);
echo $text_builder->getResult();
echo $xml_builder->getResult();
示例#10
0
<?php

if (empty($_POST['hash'])) {
    $api->outputError(30);
}
$collectionStatus = empty($_POST['collection_status']) ? Quiz::BLOCKED_STATUS_DELETED : $_POST['collection_status'];
$collection = new Quiz();
$collection = $collection->getByHash($_POST['hash']);
$collection->delete();
$blockedCollection = BlockedCollections::getByCollectionId($collection->id);
$blockedCollection->delete();
$xml = new XmlBuilder();
$xml->Push('response');
$xml->Element('code', 200);
$xml->Element('status', ServMessages::getMessage(20));
$xml->Pop('response');
$api->outputXML($xml->GetXML());
示例#11
0
<?php

if (empty($_POST['hash'])) {
    $api->outputError(30);
}
$collectionStatus = empty($_POST['collection_status']) ? Quiz::BLOCKED_STATUS_TEMP : $_POST['collection_status'];
$hash = $_POST['hash'];
$collection = new Quiz();
$collection = $collection->getByHash($hash);
// Get jobs
if ($collection->id > 0) {
    // Building xml
    $xml = new XmlBuilder();
    $xml->Push('response');
    $xml->Element('code', 200);
    $xml->Element('status', ServMessages::getMessage(20));
    $xml->Push('collection');
    $xml->Element('collection_id', $collection->id);
    $xml->Element('user_id', $collection->user_id);
    $xml->Element('hash', $collection->hash);
    $xml->Pop('collection');
    $xml->Pop('response');
    // Output xml
    $api->outputXML($xml->GetXML());
}
$api->outputError(80);
示例#12
0
 public function show(Request $request, Response $response, $args)
 {
     $kpi_active = $this->getIndicadorService()->getEntityManager()->getRepository('App\\Entity\\Kpi')->findOneByActive(1);
     $kpi = $this->getIndicadorService()->getById($kpi_active->getId());
     foreach ($kpi['fieldset_periodo'] as $key => $item) {
         $date = substr($item, -4) . '-' . substr($item, 0, 2) . '-01';
         $kpi['fieldset_periodo'][$key] = $date;
     }
     $data = array('kpi' => array('responsible' => $kpi['fieldset_informacoes']['responsible'], 'period' => array('first' => array('initial' => $kpi['fieldset_periodo']['period_first_initial'], 'end' => $kpi['fieldset_periodo']['period_first_end']), 'second' => array('initial' => $kpi['fieldset_periodo']['period_second_initial'], 'end' => $kpi['fieldset_periodo']['period_second_end']))), 'comparative' => array('groupbenner' => array('revenues' => array('initial' => number_format($kpi['fieldset_comparativo_grupobenner']['revenuesInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_grupobenner']['revenuesEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_grupobenner']['revenuesTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_grupobenner']['revenuesPercentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($kpi['fieldset_comparativo_grupobenner']['ebtidaInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_grupobenner']['ebtidaEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_grupobenner']['ebtidaTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_grupobenner']['ebtidaPercentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($kpi['fieldset_comparativo_grupobenner']['netprofitInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_grupobenner']['netprofitEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_grupobenner']['netprofitTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_grupobenner']['netprofitPercentage'], 1, '.', ''))), 'healthoperators' => array('revenues' => array('initial' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['revenuesInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['revenuesEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['revenuesTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['revenuesPercentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['ebtidaInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['ebtidaEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['ebtidaTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['ebtidaPercentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['netprofitInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['netprofitEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['netprofitTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['netprofitPercentage'], 1, '.', '')), 'distributionrevenue' => array('lu' => array('value' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['luValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['luPercentage'], 1, '.', '')), 'lum' => array('value' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['lumValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['lumPercentage'], 1, '.', '')), 'implantation' => array('value' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['implantationValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['implantationPercentage'], 1, '.', '')), 'sms' => array('value' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['smsValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['smsPercentage'], 1, '.', '')), 'medicalservices' => array('value' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['medicalServicesValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['medicalServicesPercentage'], 1, '.', '')), 'workout' => array('value' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['workoutValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_operadorasdesaude']['workoutPercentage'], 1, '.', '')))), 'hospital' => array('revenues' => array('initial' => number_format($kpi['fieldset_comparativo_hospitalar']['revenuesInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_hospitalar']['revenuesEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_hospitalar']['revenuesTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_hospitalar']['revenuesPercentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($kpi['fieldset_comparativo_hospitalar']['ebtidaInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_hospitalar']['ebtidaEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_hospitalar']['ebtidaTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_hospitalar']['ebtidaPercentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($kpi['fieldset_comparativo_hospitalar']['netprofitInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_hospitalar']['netprofitEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_hospitalar']['netprofitTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_hospitalar']['netprofitPercentage'], 1, '.', '')), 'distributionrevenue' => array('lu' => array('value' => number_format($kpi['fieldset_comparativo_hospitalar']['luValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_hospitalar']['luPercentage'], 1, '.', '')), 'lum' => array('value' => number_format($kpi['fieldset_comparativo_hospitalar']['lumValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_hospitalar']['lumPercentage'], 1, '.', '')), 'implantation' => array('value' => number_format($kpi['fieldset_comparativo_hospitalar']['implantationValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_hospitalar']['implantationPercentage'], 1, '.', '')))), 'ominousmanagement' => array('revenues' => array('initial' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['revenuesInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['revenuesEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['revenuesTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['revenuesPercentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['ebtidaInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['ebtidaEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['ebtidaTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['ebtidaPercentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['netprofitInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['netprofitEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['netprofitTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['netprofitPercentage'], 1, '.', '')), 'distributionrevenue' => array('services' => array('value' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['servicesValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_gestaodesinistro']['servicesPercentage'], 1, '.', '')))), 'systems' => array('revenues' => array('initial' => number_format($kpi['fieldset_comparativo_sistemas']['revenuesInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_sistemas']['revenuesEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_sistemas']['revenuesTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_sistemas']['revenuesPercentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($kpi['fieldset_comparativo_sistemas']['ebtidaInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_sistemas']['ebtidaEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_sistemas']['ebtidaTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_sistemas']['ebtidaPercentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($kpi['fieldset_comparativo_sistemas']['netprofitInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_comparativo_sistemas']['netprofitEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_comparativo_sistemas']['netprofitTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_sistemas']['netprofitPercentage'], 1, '.', '')), 'distributionrevenue' => array('lu' => array('value' => number_format($kpi['fieldset_comparativo_sistemas']['luValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_sistemas']['luPercentage'], 1, '.', '')), 'lum' => array('value' => number_format($kpi['fieldset_comparativo_sistemas']['lumValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_sistemas']['lumPercentage'], 1, '.', '')), 'implantation' => array('value' => number_format($kpi['fieldset_comparativo_sistemas']['implantationValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_sistemas']['implantationPercentage'], 1, '.', '')), 'sms' => array('value' => number_format($kpi['fieldset_comparativo_sistemas']['smsValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_sistemas']['smsPercentage'], 1, '.', '')), 'royaltes' => array('value' => number_format($kpi['fieldset_comparativo_sistemas']['royaltesValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_sistemas']['royaltesPercentage'], 1, '.', '')), 'maintenancepc' => array('value' => number_format($kpi['fieldset_comparativo_sistemas']['maintenancePcValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_sistemas']['maintenancePcPercentage'], 1, '.', '')), 'outsourcing' => array('value' => number_format($kpi['fieldset_comparativo_sistemas']['outsourcingValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_sistemas']['outsourcingPercentage'], 1, '.', '')), 'bpo' => array('value' => number_format($kpi['fieldset_comparativo_sistemas']['bpoValue'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_comparativo_sistemas']['bpoPercentage'], 1, '.', ''))))), 'budgeted' => array('groupbenner' => array('revenues' => array('initial' => number_format($kpi['fieldset_orcadorealizado_grupobenner']['revenuesInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_grupobenner']['revenuesEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_grupobenner']['revenuesTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_grupobenner']['revenuesPercentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($kpi['fieldset_orcadorealizado_grupobenner']['ebtidaInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_grupobenner']['ebtidaEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_grupobenner']['ebtidaTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_grupobenner']['ebtidaPercentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($kpi['fieldset_orcadorealizado_grupobenner']['netprofitInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_grupobenner']['netprofitEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_grupobenner']['netprofitTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_grupobenner']['netprofitPercentage'], 1, '.', ''))), 'healthoperators' => array('revenues' => array('initial' => number_format($kpi['fieldset_orcadorealizado_operadorasdesaude']['revenuesInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_operadorasdesaude']['revenuesEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_operadorasdesaude']['revenuesTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_operadorasdesaude']['revenuesPercentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($kpi['fieldset_orcadorealizado_operadorasdesaude']['ebtidaInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_operadorasdesaude']['ebtidaEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_operadorasdesaude']['ebtidaTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_operadorasdesaude']['ebtidaPercentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($kpi['fieldset_orcadorealizado_operadorasdesaude']['netprofitInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_operadorasdesaude']['netprofitEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_operadorasdesaude']['netprofitTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_operadorasdesaude']['netprofitPercentage'], 1, '.', ''))), 'hospital' => array('revenues' => array('initial' => number_format($kpi['fieldset_orcadorealizado_hospitalar']['revenuesInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_hospitalar']['revenuesEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_hospitalar']['revenuesTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_hospitalar']['revenuesPercentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($kpi['fieldset_orcadorealizado_hospitalar']['ebtidaInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_hospitalar']['ebtidaEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_hospitalar']['ebtidaTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_hospitalar']['ebtidaPercentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($kpi['fieldset_orcadorealizado_hospitalar']['netprofitInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_hospitalar']['netprofitEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_hospitalar']['netprofitTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_hospitalar']['netprofitPercentage'], 1, '.', ''))), 'ominousmanagement' => array('revenues' => array('initial' => number_format($kpi['fieldset_orcadorealizado_gestaodesinistro']['revenuesInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_gestaodesinistro']['revenuesEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_gestaodesinistro']['revenuesTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_gestaodesinistro']['revenuesPercentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($kpi['fieldset_orcadorealizado_gestaodesinistro']['ebtidaInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_gestaodesinistro']['ebtidaEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_gestaodesinistro']['ebtidaTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_gestaodesinistro']['ebtidaPercentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($kpi['fieldset_orcadorealizado_gestaodesinistro']['netprofitInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_gestaodesinistro']['netprofitEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_gestaodesinistro']['netprofitTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_gestaodesinistro']['netprofitPercentage'], 1, '.', ''))), 'systems' => array('revenues' => array('initial' => number_format($kpi['fieldset_orcadorealizado_sistemas']['revenuesInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_sistemas']['revenuesEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_sistemas']['revenuesTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_sistemas']['revenuesPercentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($kpi['fieldset_orcadorealizado_sistemas']['ebtidaInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_sistemas']['ebtidaEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_sistemas']['ebtidaTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_sistemas']['ebtidaPercentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($kpi['fieldset_orcadorealizado_sistemas']['netprofitInitial'], 1, '.', ''), 'end' => number_format($kpi['fieldset_orcadorealizado_sistemas']['netprofitEnd'], 1, '.', ''), 'target' => number_format($kpi['fieldset_orcadorealizado_sistemas']['netprofitTarget'], 1, '.', ''), 'percentage' => number_format($kpi['fieldset_orcadorealizado_sistemas']['netprofitPercentage'], 1, '.', '')))), 'employees' => array('initial' => array('employees' => $kpi['fieldset_colaborador_numerocolaboradores']['firstYearNumberOfEmployees'], 'icons' => $kpi['fieldset_colaborador_numerocolaboradores']['firstYearIcons'], 'billing' => number_format($kpi['fieldset_colaborador_faturamentocolaboradores']['firstYearBillingByEmployees'], 1, '.', '')), 'end' => array('employees' => $kpi['fieldset_colaborador_numerocolaboradores']['secondYearNumberOfEmployees'], 'icons' => $kpi['fieldset_colaborador_numerocolaboradores']['secondYearIcons'], 'billing' => number_format($kpi['fieldset_colaborador_faturamentocolaboradores']['secondYearBillingByEmployees'], 1, '.', ''))));
     if ($args['type'] == 'xml') {
         $xmlBuilder = new XmlBuilder('root');
         $xmlBuilder->load($data);
         $xml_output = $xmlBuilder->createXML(true);
         $finfo = new \finfo(FILEINFO_MIME_TYPE);
         $response->write($xml_output);
         $response = $response->withHeader('content-type', $finfo->buffer($xml_output));
         return $response;
     } else {
         return $response->withJson($data);
     }
 }
示例#13
0
 public function show(Request $request, Response $response, $args)
 {
     $kpi_entity = $this->em->getRepository('App\\Entity\\Kpi')->findOneByActive(1);
     $kpi_type_comparative_entity = $this->em->getRepository('App\\Entity\\KpiType')->findOneById(1);
     $kpi_type_budgeted_entity = $this->em->getRepository('App\\Entity\\KpiType')->findOneById(2);
     $criteria_comparative = Criteria::create();
     $criteria_comparative->where(Criteria::expr()->eq('kpi', $kpi_entity));
     $criteria_comparative->andWhere(Criteria::expr()->eq('kpiType', $kpi_type_comparative_entity));
     $criteria_budgeted = Criteria::create();
     $criteria_budgeted->where(Criteria::expr()->eq('kpi', $kpi_entity));
     $criteria_budgeted->andWhere(Criteria::expr()->eq('kpiType', $kpi_type_budgeted_entity));
     $data = ['kpi' => (new ClassMethods())->extract($kpi_entity), 'comparative' => ['groupbenner' => (new ClassMethods())->extract($this->em->getRepository('App\\Entity\\GroupBenner')->matching($criteria_comparative)->first()), 'healthoperators' => (new ClassMethods())->extract($this->em->getRepository('App\\Entity\\HealthOperators')->matching($criteria_comparative)->first()), 'hospital' => (new ClassMethods())->extract($this->em->getRepository('App\\Entity\\Hospital')->matching($criteria_comparative)->first()), 'ominousmanagement' => (new ClassMethods())->extract($this->em->getRepository('App\\Entity\\OminousManagement')->matching($criteria_comparative)->first()), 'systems' => (new ClassMethods())->extract($this->em->getRepository('App\\Entity\\Systems')->matching($criteria_comparative)->first())], 'budgeted' => ['groupbenner' => (new ClassMethods())->extract($this->em->getRepository('App\\Entity\\GroupBenner')->matching($criteria_budgeted)->first()), 'healthoperators' => (new ClassMethods())->extract($this->em->getRepository('App\\Entity\\HealthOperators')->matching($criteria_budgeted)->first()), 'hospital' => (new ClassMethods())->extract($this->em->getRepository('App\\Entity\\Hospital')->matching($criteria_budgeted)->first()), 'ominousmanagement' => (new ClassMethods())->extract($this->em->getRepository('App\\Entity\\OminousManagement')->matching($criteria_budgeted)->first()), 'systems' => (new ClassMethods())->extract($this->em->getRepository('App\\Entity\\Systems')->matching($criteria_budgeted)->first())], 'employees' => (new ClassMethods())->extract($this->em->getRepository('App\\Entity\\Employees')->findOneByKpi($kpi_entity))];
     $data['kpi']['period_first_initial'] = $data['kpi']['period_first_initial']->format('Y-m-d');
     $data['kpi']['period_first_end'] = $data['kpi']['period_first_end']->format('Y-m-d');
     $data['kpi']['period_second_initial'] = $data['kpi']['period_second_initial']->format('Y-m-d');
     $data['kpi']['period_second_end'] = $data['kpi']['period_second_end']->format('Y-m-d');
     unset($data['kpi']['id'], $data['kpi']['created_at'], $data['kpi']['updated_at'], $data['kpi']['deleted_at'], $data['kpi']['active']);
     unset($data['comparative']['groupbenner']['id'], $data['comparative']['groupbenner']['created_at'], $data['comparative']['groupbenner']['updated_at'], $data['comparative']['groupbenner']['deleted_at'], $data['comparative']['groupbenner']['kpi_type'], $data['comparative']['groupbenner']['kpi']);
     unset($data['comparative']['healthoperators']['id'], $data['comparative']['healthoperators']['created_at'], $data['comparative']['healthoperators']['updated_at'], $data['comparative']['healthoperators']['deleted_at'], $data['comparative']['healthoperators']['kpi_type'], $data['comparative']['healthoperators']['kpi']);
     unset($data['comparative']['hospital']['id'], $data['comparative']['hospital']['created_at'], $data['comparative']['hospital']['updated_at'], $data['comparative']['hospital']['deleted_at'], $data['comparative']['hospital']['kpi_type'], $data['comparative']['hospital']['kpi']);
     unset($data['comparative']['ominousmanagement']['id'], $data['comparative']['ominousmanagement']['created_at'], $data['comparative']['ominousmanagement']['updated_at'], $data['comparative']['ominousmanagement']['deleted_at'], $data['comparative']['ominousmanagement']['kpi_type'], $data['comparative']['ominousmanagement']['kpi']);
     unset($data['comparative']['systems']['id'], $data['comparative']['systems']['created_at'], $data['comparative']['systems']['updated_at'], $data['comparative']['systems']['deleted_at'], $data['comparative']['systems']['kpi_type'], $data['comparative']['systems']['kpi']);
     unset($data['budgeted']['groupbenner']['id'], $data['budgeted']['groupbenner']['created_at'], $data['budgeted']['groupbenner']['updated_at'], $data['budgeted']['groupbenner']['deleted_at'], $data['budgeted']['groupbenner']['kpi_type'], $data['budgeted']['groupbenner']['kpi']);
     unset($data['budgeted']['healthoperators']['id'], $data['budgeted']['healthoperators']['created_at'], $data['budgeted']['healthoperators']['updated_at'], $data['budgeted']['healthoperators']['deleted_at'], $data['budgeted']['healthoperators']['kpi_type'], $data['budgeted']['healthoperators']['kpi']);
     unset($data['budgeted']['hospital']['id'], $data['budgeted']['hospital']['created_at'], $data['budgeted']['hospital']['updated_at'], $data['budgeted']['hospital']['deleted_at'], $data['budgeted']['hospital']['kpi_type'], $data['budgeted']['hospital']['kpi']);
     unset($data['budgeted']['ominousmanagement']['id'], $data['budgeted']['ominousmanagement']['created_at'], $data['budgeted']['ominousmanagement']['updated_at'], $data['budgeted']['ominousmanagement']['deleted_at'], $data['budgeted']['ominousmanagement']['kpi_type'], $data['budgeted']['ominousmanagement']['kpi']);
     unset($data['budgeted']['systems']['id'], $data['budgeted']['systems']['created_at'], $data['budgeted']['systems']['updated_at'], $data['budgeted']['systems']['deleted_at'], $data['budgeted']['systems']['kpi_type'], $data['budgeted']['systems']['kpi']);
     $kpi = array('responsible' => $data['kpi']['responsible'], 'period' => array('first' => array('initial' => $data['kpi']['period_first_initial'], 'end' => $data['kpi']['period_first_end']), 'second' => array('initial' => $data['kpi']['period_second_initial'], 'end' => $data['kpi']['period_second_end'])));
     $comparative = array('groupbenner' => array('revenues' => array('initial' => number_format($data['comparative']['groupbenner']['revenues_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['groupbenner']['revenues_end'], 1, '.', ''), 'target' => number_format($data['comparative']['groupbenner']['revenues_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['groupbenner']['revenues_percentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($data['comparative']['groupbenner']['ebtida_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['groupbenner']['ebtida_end'], 1, '.', ''), 'target' => number_format($data['comparative']['groupbenner']['ebtida_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['groupbenner']['ebtida_percentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($data['comparative']['groupbenner']['net_profit_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['groupbenner']['net_profit_end'], 1, '.', ''), 'target' => number_format($data['comparative']['groupbenner']['net_profit_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['groupbenner']['net_profit_percentage'], 1, '.', ''))), 'healthoperators' => array('revenues' => array('initial' => number_format($data['comparative']['healthoperators']['revenues_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['healthoperators']['revenues_end'], 1, '.', ''), 'target' => number_format($data['comparative']['healthoperators']['revenues_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['healthoperators']['revenues_percentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($data['comparative']['healthoperators']['ebtida_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['healthoperators']['ebtida_end'], 1, '.', ''), 'target' => number_format($data['comparative']['healthoperators']['ebtida_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['healthoperators']['ebtida_percentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($data['comparative']['healthoperators']['net_profit_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['healthoperators']['net_profit_end'], 1, '.', ''), 'target' => number_format($data['comparative']['healthoperators']['net_profit_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['healthoperators']['net_profit_percentage'], 1, '.', '')), 'distributionrevenue' => array('lu' => array('value' => number_format($data['comparative']['healthoperators']['lu_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['healthoperators']['lu_percentage'], 1, '.', '')), 'lum' => array('value' => number_format($data['comparative']['healthoperators']['lum_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['healthoperators']['lum_percentage'], 1, '.', '')), 'implantation' => array('value' => number_format($data['comparative']['healthoperators']['implantation_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['healthoperators']['implantation_percentage'], 1, '.', '')), 'sms' => array('value' => number_format($data['comparative']['healthoperators']['sms_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['healthoperators']['sms_percentage'], 1, '.', '')), 'medicalservices' => array('value' => number_format($data['comparative']['healthoperators']['medical_services_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['healthoperators']['medical_services_percentage'], 1, '.', '')), 'workout' => array('value' => number_format($data['comparative']['healthoperators']['workout_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['healthoperators']['workout_percentage'], 1, '.', '')))), 'hospital' => array('revenues' => array('initial' => number_format($data['comparative']['hospital']['revenues_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['hospital']['revenues_end'], 1, '.', ''), 'target' => number_format($data['comparative']['hospital']['revenues_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['hospital']['revenues_percentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($data['comparative']['hospital']['ebtida_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['hospital']['ebtida_end'], 1, '.', ''), 'target' => number_format($data['comparative']['hospital']['ebtida_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['hospital']['ebtida_percentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($data['comparative']['hospital']['net_profit_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['hospital']['net_profit_end'], 1, '.', ''), 'target' => number_format($data['comparative']['hospital']['net_profit_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['hospital']['net_profit_percentage'], 1, '.', '')), 'distributionrevenue' => array('lu' => array('value' => number_format($data['comparative']['hospital']['lu_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['hospital']['lu_percentage'], 1, '.', '')), 'lum' => array('value' => number_format($data['comparative']['hospital']['lum_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['hospital']['lum_percentage'], 1, '.', '')), 'implantation' => array('value' => number_format($data['comparative']['hospital']['implantation_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['hospital']['implantation_percentage'], 1, '.', '')))), 'ominousmanagement' => array('revenues' => array('initial' => number_format($data['comparative']['ominousmanagement']['revenues_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['ominousmanagement']['revenues_end'], 1, '.', ''), 'target' => number_format($data['comparative']['ominousmanagement']['revenues_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['ominousmanagement']['revenues_percentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($data['comparative']['ominousmanagement']['ebtida_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['ominousmanagement']['ebtida_end'], 1, '.', ''), 'target' => number_format($data['comparative']['ominousmanagement']['ebtida_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['ominousmanagement']['ebtida_percentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($data['comparative']['ominousmanagement']['net_profit_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['ominousmanagement']['net_profit_end'], 1, '.', ''), 'target' => number_format($data['comparative']['ominousmanagement']['net_profit_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['ominousmanagement']['net_profit_percentage'], 1, '.', '')), 'distributionrevenue' => array('services' => array('value' => number_format($data['comparative']['ominousmanagement']['services_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['ominousmanagement']['services_percentage'], 1, '.', '')))), 'systems' => array('revenues' => array('initial' => number_format($data['comparative']['systems']['revenues_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['systems']['revenues_end'], 1, '.', ''), 'target' => number_format($data['comparative']['systems']['revenues_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['systems']['revenues_percentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($data['comparative']['systems']['ebtida_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['systems']['ebtida_end'], 1, '.', ''), 'target' => number_format($data['comparative']['systems']['ebtida_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['systems']['ebtida_percentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($data['comparative']['systems']['net_profit_initial'], 1, '.', ''), 'end' => number_format($data['comparative']['systems']['net_profit_end'], 1, '.', ''), 'target' => number_format($data['comparative']['systems']['net_profit_target'], 1, '.', ''), 'percentage' => number_format($data['comparative']['systems']['net_profit_percentage'], 1, '.', '')), 'distributionrevenue' => array('lu' => array('value' => number_format($data['comparative']['systems']['lu_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['systems']['lu_percentage'], 1, '.', '')), 'lum' => array('value' => number_format($data['comparative']['systems']['lum_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['systems']['lum_percentage'], 1, '.', '')), 'implantation' => array('value' => number_format($data['comparative']['systems']['implantation_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['systems']['implantation_percentage'], 1, '.', '')), 'sms' => array('value' => number_format($data['comparative']['systems']['sms_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['systems']['sms_percentage'], 1, '.', '')), 'royaltes' => array('value' => number_format($data['comparative']['systems']['royaltes_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['systems']['royaltes_percentage'], 1, '.', '')), 'maintenancepc' => array('value' => number_format($data['comparative']['systems']['maintenance_pc_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['systems']['maintenance_pc_percentage'], 1, '.', '')), 'outsourcing' => array('value' => number_format($data['comparative']['systems']['outsourcing_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['systems']['outsourcing_percentage'], 1, '.', '')), 'bpo' => array('value' => number_format($data['comparative']['systems']['bpo_value'], 1, '.', ''), 'percentage' => number_format($data['comparative']['systems']['bpo_percentage'], 1, '.', '')))));
     $budgeted = array('groupbenner' => array('revenues' => array('initial' => number_format($data['budgeted']['groupbenner']['revenues_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['groupbenner']['revenues_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['groupbenner']['revenues_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['groupbenner']['revenues_percentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($data['budgeted']['groupbenner']['ebtida_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['groupbenner']['ebtida_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['groupbenner']['ebtida_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['groupbenner']['ebtida_percentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($data['budgeted']['groupbenner']['net_profit_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['groupbenner']['net_profit_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['groupbenner']['net_profit_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['groupbenner']['net_profit_percentage'], 1, '.', ''))), 'healthoperators' => array('revenues' => array('initial' => number_format($data['budgeted']['healthoperators']['revenues_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['healthoperators']['revenues_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['healthoperators']['revenues_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['healthoperators']['revenues_percentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($data['budgeted']['healthoperators']['ebtida_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['healthoperators']['ebtida_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['healthoperators']['ebtida_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['healthoperators']['ebtida_percentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($data['budgeted']['healthoperators']['net_profit_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['healthoperators']['net_profit_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['healthoperators']['net_profit_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['healthoperators']['net_profit_percentage'], 1, '.', ''))), 'hospital' => array('revenues' => array('initial' => number_format($data['budgeted']['hospital']['revenues_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['hospital']['revenues_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['hospital']['revenues_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['hospital']['revenues_percentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($data['budgeted']['hospital']['ebtida_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['hospital']['ebtida_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['hospital']['ebtida_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['hospital']['ebtida_percentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($data['budgeted']['hospital']['net_profit_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['hospital']['net_profit_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['hospital']['net_profit_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['hospital']['net_profit_percentage'], 1, '.', '')), 'distributionrevenue' => array('lu' => array('value' => number_format($data['budgeted']['hospital']['lu_value'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['hospital']['lu_percentage'], 1, '.', '')), 'lum' => array('value' => number_format($data['budgeted']['hospital']['lum_value'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['hospital']['lum_percentage'], 1, '.', '')), 'implantation' => array('value' => number_format($data['budgeted']['hospital']['implantation_value'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['hospital']['implantation_percentage'], 1, '.', '')))), 'ominousmanagement' => array('revenues' => array('initial' => number_format($data['budgeted']['ominousmanagement']['revenues_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['ominousmanagement']['revenues_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['ominousmanagement']['revenues_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['ominousmanagement']['revenues_percentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($data['budgeted']['ominousmanagement']['ebtida_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['ominousmanagement']['ebtida_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['ominousmanagement']['ebtida_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['ominousmanagement']['ebtida_percentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($data['budgeted']['ominousmanagement']['net_profit_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['ominousmanagement']['net_profit_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['ominousmanagement']['net_profit_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['ominousmanagement']['net_profit_percentage'], 1, '.', ''))), 'systems' => array('revenues' => array('initial' => number_format($data['budgeted']['systems']['revenues_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['systems']['revenues_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['systems']['revenues_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['systems']['revenues_percentage'], 1, '.', '')), 'ebtida' => array('initial' => number_format($data['budgeted']['systems']['ebtida_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['systems']['ebtida_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['systems']['ebtida_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['systems']['ebtida_percentage'], 1, '.', '')), 'netprofit' => array('initial' => number_format($data['budgeted']['systems']['net_profit_initial'], 1, '.', ''), 'end' => number_format($data['budgeted']['systems']['net_profit_end'], 1, '.', ''), 'target' => number_format($data['budgeted']['systems']['net_profit_target'], 1, '.', ''), 'percentage' => number_format($data['budgeted']['systems']['net_profit_percentage'], 1, '.', ''))));
     $employees = array('initial' => array('employees' => $data['employees']['contributors1_year_number_of_employees'], 'icons' => $data['employees']['contributors1_year_icons'], 'billing' => $data['employees']['contributors1_year_billing_by_employees']), 'end' => array('employees' => $data['employees']['contributors2_year_number_of_employees'], 'icons' => $data['employees']['contributors2_year_icons'], 'billing' => $data['employees']['contributors2_year_billing_by_employees']));
     $data = array('kpi' => $kpi, 'comparative' => $comparative, 'budgeted' => $budgeted, 'employees' => $employees);
     if ($args['type'] == 'xml') {
         $xmlBuilder = new XmlBuilder('root');
         $xmlBuilder->load($data);
         $xml_output = $xmlBuilder->createXML(true);
         $finfo = new \finfo(FILEINFO_MIME_TYPE);
         $response->write($xml_output);
         $response = $response->withHeader('content-type', $finfo->buffer($xml_output));
         return $response;
     } else {
         return $response->withJson($data);
     }
 }