public function createFZinfo($fzData, $cinputs, $noenergie = false) { $session = $this->soapsession; $templateclient = getSoapClient('template'); $documentclient = getSoapClient('document'); $sessionclient = getSoapClient('session'); $ticketclient = getSoapClient('ticket'); if ($noenergie == false) { $eObj = $fzData[1]; $co2val = strlen($eObj->co2) < 3 ? '0' . $eObj->co2 : $eObj->co2; $eArr = array('Marke' => $eObj->markeBez, 'Typ' => $eObj->typBez, 'Treibstoff' => $eObj->treibstoff, 'Getriebeart' => $eObj->getriebeart, 'Leergewicht' => $eObj->leergewicht, 'Verbrauch' => $eObj->verbrauch, 'CO2' => $eObj->co2, 'Emissionsbild' => 'CO2_' . $co2val . '.eps', 'Kategoriebild' => 'Kategorie' . $eObj->energieeffizienz . '.eps'); $iSessionArr = array(); foreach ($eArr as $item => $value) { $eArr[$item] = urldecode($value); // Mage::log("$item: " . urldecode($value)); $res = makeSoapCall($sessionclient, 'session_setValue', array($session, $item, urldecode($value))); } // $res = makeSoapCall($sessionclient, 'session_setValueList', array($session, $iSessionArr)); // exit; } $dObj = $fzData[0]; $dArr = array('Typencode' => $dObj->markeBezeichnung, 'Modell' => $dObj->basisModellInfo->modellBezeichnung, 'Motor' => $dObj->basisModellInfo->motorBezeichnung, 'Getriebe' => $dObj->basisModellInfo->getriebeBezeichnung, 'Bauart' => $dObj->basisModellInfo->motorBauart, 'LeistungKw' => $dObj->basisModellInfo->leistungKw, 'LeistungPs' => $dObj->basisModellInfo->leistungPs, 'Basismodell' => $dObj->basisModellInfo->modellBezeichnung, 'PreisModellBasis' => setQuotes($dObj->basisModellInfo->grundpreis), 'ModellAM' => $dObj->modellInfo->modellLinie, 'MotorAM' => $dObj->modellInfo->motorBezeichnung, 'GetriebeAM' => $dObj->modellInfo->getriebeBezeichnung, 'BauartAM' => $dObj->modellInfo->motorBauart, 'LeistungKwAM' => $dObj->modellInfo->leistungKw, 'LeistungPsAM' => $dObj->modellInfo->leistungPs, 'PreisModellAM' => setQuotes($dObj->modellInfo->grundpreis)); $i = 1; if (isset($dObj->iconInfos->array) && is_array($dObj->iconInfos->array)) { foreach ($dObj->iconInfos->array as $item) { $dArr['Picto' . $i] = str_replace(' ', '', $item->iconName) . '_' . strtolower($cinputs['lang']) . '.psd'; $i++; } } $i = 1; $nStr = ''; $preisam = $dObj->modellInfo->grundpreis; if (!isset($dObj->highlights->array)) { $dObj->highlights->array = array(); } foreach ($dObj->highlights->array as $item) { $nStr = leadingZero($i); $fussnote = $item->fussnote ? '|' . $item->fussnote : ''; $dArr['Ausstattung' . $nStr] = $item->text . $fussnote; $i++; } while ($i < 21) { $nStr = leadingZero($i); $dArr['Ausstattung' . $nStr] = 'KEINE'; $i++; } $i = 1; if (!isset($dObj->options->array)) { $dObj->options->array = array(); } if (!is_array($dObj->options->array)) { $dObj->options->array = array($dObj->options->array); } foreach ($dObj->options->array as $item) { $nStr = leadingZero($i); $fussnote = $item->fussnote ? '|' . $item->fussnote : ''; $dArr['Option' . $nStr] = $item->bezeichnung . $fussnote; $dArr['PreisOp' . $nStr] = setQuotes($item->preis); $preisam = $preisam + $item->preis; $i++; } for ($a = 1; $a < 5; $a++) { $nStr = leadingZero($i); if ($cinputs['opt' . $a] == '') { continue; } $dArr['Option' . $nStr] = $cinputs['opt' . $a]; if ($cinputs['val' . $a] != '') { $dArr['PreisOp' . $nStr] = setQuotes((int) $cinputs['val' . $a]); try { $preisam = $preisam + (int) $cinputs['val' . $a]; } catch (Exception $e) { } } $i++; } // while ($i < 21) { // $nStr = leadingZero($i); // $dArr['Option' . $nStr] = 'KEINE'; // $i++; // } /** * missing in Obj: PreisLieferung, PreisLeasing * $dArr['PreisLieferung'] = ???; * $dArr['PreisLeasing'] = ???; */ if (isset($cinputs['auslieferung']) && $cinputs['auslieferung'] !== '') { $dArr['Ablieferungspauschale'] = $cinputs['Ablieferungspauschale']; $dArr['PreisLieferung'] = 'CHF ' . setQuotes($cinputs['auslieferung']); try { $preisam = $preisam + (int) $cinputs['auslieferung']; } catch (Exception $e) { } } $dArr['PreisTotal'] = setQuotes($preisam); $dArr['Währung'] = 'CHF'; if (isset($cinputs['leasing_monatlich']) && $cinputs['leasing_monatlich'] !== '') { $dArr['St'] = '*'; $dArr['PreisLeasing'] = 'CHF ' . setQuotes($cinputs['leasing_monatlich']); $dArr['MonateLeasing'] = $cinputs['leasing_dauer']; $dArr['KmMaxLeasing'] = $cinputs['leasing_kilometer']; $dArr['RestwertLeasing'] = setQuotes($cinputs['leasing_restwert']); $dArr['SonderLeasing'] = setQuotes($cinputs['leasing_anzahlung']); $dArr['ZsLeasing'] = $cinputs['leasing_zinssatz']; $dArr['ZinsEffLeasing'] = $cinputs['leasing_jahreszins']; $dArr['Leasing'] = $cinputs['Leasing']; $dArr['Leasingtext'] = $cinputs['Leasingtext']; // $dArr['Leasing'] = 'Leasing ' . $cinputs['leasing_dauer'] . ' Monate, ' . $cinputs['leasing_zinssatz'] . '%, bereits ab '; // $dArr['Leasingtext'] = 'Leasingzins CHF ' . setQuotes(number_format($cinputs['leasing_monatlich'], 2, '.', '')) . ' mtl., inkl. MwSt. bei ' // . $cinputs['leasing_dauer'] . ' Monaten Laufzeit und ' . $cinputs['leasing_kilometer'] // . 'km/Jahr. Sonderzahlung CHF ' . setQuotes(number_format($cinputs['leasing_anzahlung'], 2, '.', '')) // . ', Restwert CHF ' . setQuotes(number_format($cinputs['leasing_restwert'], 2, '.', '')) // . ', Kaution vom Finanzierungsbetrag 5% (mindestens CHF 1000.-), effektiver Jahreszins ' // . $cinputs['leasing_jahreszins'] . '%, Vollkaskoversicherung obligatorisch. Weitere Berechnungsvarianten auf Anfrage. ' // . 'Eine Leasingvergabe wird nicht gewährt, falls Sie zur Überschuldung des Konsumenten führt.'; } // var_dump($dArr); // exit; foreach ($dArr as $item => $value) { // Mage::log("$item: " . serialize($value)); // $dArr[$item] = urldecode($value); $res = makeSoapCall($sessionclient, 'session_setValue', array($session, $item, urldecode($value))); } // $res = makeSoapCall($sessionclient, 'session_setValueList', array($session, $dArr)); $lang = 'de_DE'; switch ($cinputs['lang']) { case 'DE': $lang = 'de_DE'; break; case 'FR': $lang = 'fr_FR'; break; case 'IT': $lang = 'it_IT'; } $templatelist = makeSoapCall($templateclient, 'template_getTemplateList', array('categories' => '', 'sessionid' => $session)); if (is_object($templatelist) && is_array($templatelist->item)) { $templatename = $noenergie ? 'Preisblatt_Toyota_' : 'Preisblatt_energieEtikette_Toyota_'; foreach ($templatelist->item as $template) { if ($template->title == $templatename . $cinputs['lang']) { $templateid = $template->id; } } } if (!isset($templateid)) { Mage::log('no templateid found for name: ' . $templatename . $cinputs['lang']); return false; } $ticket = makeSoapCall($documentclient, 'document_create', array('templateid' => $templateid, 'title' => '', 'description' => '', 'sessionid' => $session, 'language' => $lang)); /** ticket getStatus */ $status = $this->_checkTicket($ticket, $session); if ($status == 'READY') { /** ticket getResult */ $ticketresult = makeSoapCall($ticketclient, 'ticket_getResult', array('ticketlist' => array($ticket->id), 'sessionid' => $session)); //Zend_Debug::dump($ticketresult, 'ticketresult'); } else { // Mage::log($status . 'ticketresult'); return false; } $documentid = $ticketresult->item->result; $ticket = makeSoapCall($documentclient, 'document_createPDF', array('documentid' => $documentid, 'quality' => 'Preview', 'sessionid' => $session)); // check status of ticket $status = $this->_checkTicket($ticket, $session); // if ($status == 'READY') { // ticket getResult $ticketresult = makeSoapCall($ticketclient, 'ticket_getResult', array('ticketlist' => array($ticket->id), 'sessionid' => $session)); } else { return false; } // $res = makeSoapCall($sessionclient, 'session_unsetValueList', array($session, array_merge($eArr, $dArr))); if (!$noenergie) { foreach ($eArr as $item => $value) { $res = makeSoapCall($sessionclient, 'session_unsetValue', array($session, $item)); } } foreach ($dArr as $item => $value) { $res = makeSoapCall($sessionclient, 'session_unsetValue', array($session, $item)); } return $ticketresult; }
function contentSetValuesStr($tag = "", $Item = array(), $limit = 2) { if (is_object($tag)) { $tag = $tag->outerHtml(); } if (!is_array($Item)) { $Item = array($Item); } if (is_string($tag)) { //$tag=strtr($tag,array("%7B%7B"=>"{{","%7D%7D"=>"}}")); $tag = str_replace("%7B%7B", "{{", $tag); $tag = str_replace("%7D%7D", "}}", $tag); if (strpos($tag, '}}') !== false) { // функция подставляющая значения $tag = changeQuot($tag); // заменяем " на " $spec = array('_form', '_mode', '_item', '_id'); $exit = false; $err = false; $nIter = 0; $mask = '`(\\{\\{){1,1}(%*[\\w\\d]+|_form|_mode|_item|((_SETT|_SETTINGS|_SESS|_SESSION|_SRV|_COOK|_COOKIE|$_ENV|_REQ|_GET|_POST|%*[\\w\\d]+)?([\\[]{1,1}(%*[\\w\\d]+|"%*[\\w\\d]+")[\\]]{1,1})*))(\\}\\}){1,1}`u'; while (!$exit) { $nUndef = 0; $nSub = preg_match_all($mask, $tag, $res, PREG_OFFSET_CAPTURE); // найти все вставки, не содержащие в себе других вставок if ($nSub !== false) { if ($nSub == 0) { $exit = true; } else { $text = ''; $startIn = 0; // начальная позиция текста за предыдущей заменой for ($i = 0; $i < $nSub; $i++) { $In = $res[2][$i][0]; // текст вставки без скобок {{ и }} $beforSize = $res[2][$i][1] - 2 - $startIn; $text .= substr($tag, $startIn, $beforSize); // исходный текст между предыдущей и текущей вставками $default = false; $special = 0; switch ($res[4][$i][0]) { case '_SETT': $sub = '$_SESSION["settings"]'; break; case '_SETTINGS': $sub = '$_SESSION["settings"]'; break; case '_SESS': $sub = '$_SESSION'; break; case '_SESSION': $sub = '$_SESSION'; break; case '_COOK': $sub = '$_COOKIE'; break; case '_COOKIE': $sub = '$_COOKIE'; break; case '_REQ': $sub = '$_REQUEST'; break; case '_GET': $sub = '$_GET'; break; case '_ENV': $sub = '$_ENV'; break; case '_SRV': $sub = '$_SERVER'; break; case '_POST': $sub = '$_POST'; break; case '': if (in_array($In, $spec)) { $sub = '$_GET'; $In = substr($In, 1, strlen($In) - 1); // убираем символ _ в начале if (!isset($_GET["item"]) and $In == 'item') { $In = 'id'; } if (!isset($_GET["id"]) and $In == 'id') { $In = 'item'; } } else { $sub = '$Item'; } break; default: // 1ый индекс без скобок [] - префикса нет $sub = '$Item'; $default = true; $n = strlen($res[4][$i][0]); $In = '[' . substr($In, 0, $n) . ']' . substr($In, $n, strlen($In) - $n); break; } if ($default) { $pos = 0; } else { $pos = strlen($res[4][$i][0]); } $sub .= setQuotes(substr($In, $pos, strlen($In) - $pos)); // индексная часть текущей вставки с добавленными кавычками у текстовых индексов if (eval('return isset(' . $sub . ');')) { if (eval('return is_array(' . $sub . ');')) { $text .= eval('return json_encode(' . $sub . ');'); } else { $temp = ""; eval('$temp .= ' . $sub . ';'); $temp = strtr($temp, array("{{" => "#~#~", "}}" => "~#~#")); $text .= $temp; } } else { /* $skip=array("_GET","_POST","_COOK","_COOKIE","_SESS","_SESSION","_SETT","_SETTINGS"); $tmp=explode("[",$res[2][$i][0]); $tmp=$tmp[0]; if (in_array($tmp,$skip)) { $text.=""; } else { $text .= '{{' . $res[2][$i][0] . '}}';; } */ $text .= ""; $nUndef++; } $startIn += $beforSize + strlen($res[2][$i][0]) + 4; if ($i + 1 == $nSub) { $text .= substr($tag, $startIn, strlen($tag) - $startIn); } } $tag = $text; } } $nIter++; if ($limit > 0 and $nIter == $limit) { $exit = true; } if ($nUndef == $nSub) { $exit = true; } } if (isset($_GET["mode"]) && $_GET["mode"] == "edit") { $tag = ki::fromString($tag); foreach ($tag->find("pre") as $pre) { $pre->html(htmlspecialchars($pre->html())); } unset($pre); $tag = $tag->htmlOuter(); } } $tag = strtr($tag, array("#~#~" => "{{", "~#~#" => "}}")); return $tag; } }