/** * plgVmDisplayListFE * This event is fired to display the pluginmethods in the cart (edit shipment/payment) for exampel * * @param object $cart Cart object * @param integer $selected ID of the method selected * @return boolean True on succes, false on failures, null when this plugin was not selected. * On errors, JError::raiseWarning (or JError::raiseError) must be used to set a message. * * @author Valerie Isaksen * @author Max Milbers */ public function plgVmDisplayListFEShipment(VirtueMartCart $cart, $selected = 0, &$htmlIn) { $js_html = ''; if ($this->getPluginMethods($cart->vendorId) === 0) { return FALSE; } require_once dirname(__FILE__) . DS . 'helper.php'; $address = $cart->ST == 0 ? $cart->BT : $cart->ST; $is_cz = $this->isCz($address['virtuemart_country_id']); $is_sk = $this->isSk($address['virtuemart_country_id']); $html = array(); $method_name = $this->_psType . '_name'; $document = JFactory::getDocument(); foreach ($this->methods as $key => $method) { if (!$this->checkConditions($cart, $method, $cart->pricesUnformatted)) { continue; } $mymethod = $method; $cache_d = JPATH_CACHE . DS . 'ulozenka' . DS . 'ulozenka_html_' . $method->partners . '_' . $is_cz . '_' . $is_sk . '_' . $method->virtuemart_shipmentmethod_id . '.html'; if (file_exists($cache_d)) { $html[$key] .= file_get_contents($cache_d); } else { $xml = UlozenkaHelper::getPobocky($method); $html[$key] = ''; if (isset($xml->pobocky)) { if (count($xml->pobocky)) { //JHTML::_('behavior.modal', 'a.modal'); $html[$key] .= ''; $k = 1; $first = true; $pobocky_options = array(); $js_adresa = "\n\nvar adresa=new Array();"; $js_oteviraci_doba = "\n\nvar oteviraci_doba=new Array();"; $js_cena = "\n\nvar cena=new Array();"; $js_values = "\n\nvar values=new Array();"; // $js_mapa="\n\nvar mapa=new Array();"; $first_opt = 0; $ind = 0; $pobocky_html = ''; foreach ($xml->pobocky as $p) { if ($is_sk) { if ($p->country != 'SVK') { continue; } } if ($is_cz) { if ($p->country != 'CZE') { continue; } } if (empty($method->partners)) { if (!empty($p->parner)) { continue; } } $enabled_const = 'ULOZENKA_' . strtoupper((string) $p->zkratka) . '_ENABLED'; if (defined($enabled_const)) { if (constant($enabled_const) == 1) { $enabled = true; } else { $enabled = false; } } else { $enabled = true; } $enabled_const = 'enabled' . $p->id; if (isset($method->pobocky->{$enabled_const}) && $method->pobocky->{$enabled_const}) { $enabled = true; } else { $enabled = false; } if ($enabled) { if ((string) $p->aktiv) { //$price_const = 'ULOZENKA_'.strtoupper((string)$p->zkratka).'_PRICE'; $session = JFactory::getSession(); $first_opt = $session->get('ulozenka_pobocka', $first_opt); $mk = 0; if (empty($first_opt)) { $first_opt = $p->id; } if ($first_opt == $p->id) { $sind = $ind; } $ind++; //$pobocky_options[] = JHTML::_('select.option', $p->id, $p->nazev ); $opobocka = new stdClass(); $opobocka->id = $p->id; $opobocka->nazev = $p->nazev; $pobocky_options[] = $opobocka; //$pobocky_options[] = JHTML::_('select.option', $p->id, $p->nazev ); $js_adresa .= "\nadresa[" . $p->id . "]='<b>" . $p->nazev . '</b><br />' . $p->ulice . '<br />' . $p->obec . '<br />' . $p->psc . "';"; $p->provoz = str_replace("\n\r", '', $p->provoz); $p->provoz = str_replace("\n", '', $p->provoz); $js_oteviraci_doba .= "\noteviraci_doba[" . $p->id . "]='" . $p->provoz . "';"; $pobocky_html .= $this->renderByLayout('pobocka', array('pobocka' => $p, 'sind' => $sind)); //$js_mapa.="\nmapa[".$p->id."]='".$p->mapa."';"; } } } if ($first) { $cena = ''; $output1 = $this->renderByLayout('pobocky', array('virtuemart_shipmentmethod_id' => $method->virtuemart_shipmentmethod_id, 'first_opt' => $first_opt, 'method' => $method)); $detail_url = JURI::root() . 'plugins/vmshipment/ulozenka/detail_pobocky.php?id=' . (string) $p->id; $first = false; } $pobocky = $this->renderByLayout('pobocky_select', array('pobocky_options' => $pobocky_options, 'virtuemart_shipmentmethod_id' => $method->virtuemart_shipmentmethod_id, 'xml' => $xml, 'sind' => $sind, 'method' => $method)); $html[$key] .= str_replace('{combobox}', $pobocky, $output1); $html[$key] .= $pobocky_html; $html[$key] .= "\n"; JFile::write($cache_d, $html[$key]); } // pobocky not empty } // isset pobocky } // end of ... if not cache ... } // end of foreach if (isset($mymethod)) { if (!defined('ulozenka_javascript')) { $document->addScriptDeclaration("\n" . '//<![CDATA[' . "\n" . "\n\nvar detail_url='" . JURI::root() . "plugins/vmshipment/ulozenka/detail_pobocky.php?id=';\n" . "\n\n\n\t\t\t\tfunction changeUlozenka(id, update) {\n\t\t\t\t if (typeof jQuery != 'undefined')\n\t\t\t\t\t jQuery('.zasielka_div1').not('#ulozenka_branch_' + id).hide();\n\t\t\t\t\tdocument.getElementById('ulozenka_pobocka').value=id;\n\t\t\t\t\t\n\t\t\t\t\tvar d = document.getElementById('ulozenka_saved'); \n\t\t\t\t\tif (d != null)\n\t\t\t\t\td.value = id; \n\t\t\t\t\tif (update)\n\t\t\t\t\t{\n\t\t\t\t\tdocument.getElementById('ulozenka_branch_'+id).style.display='block';\n\t\t\t\t\tif (typeof jQuery != 'undefined')\n\t\t\t\t\t{\n\t\t\t\t\t jQuery('#shipment_id_" . $method->virtuemart_shipmentmethod_id . "').click(); \n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\tdocument.getElementById('shipment_id_" . $method->virtuemart_shipmentmethod_id . "').onclick();\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof Onepage != 'undefined')\n\t\t\t\t\tOnepage.changeTextOnePage3();\n\t\t\t\t\t\n\t\t\t\t};\n" . '//]]>' . "\n"); define('ulozenka_javascript', true); } } if (empty($html)) { return FALSE; } $htmlIn[] = $html; return TRUE; }
$db->setQuery($q); $params = $db->loadResult(); $err = true; if (empty($params)) { $err = true; } else { $a = explode('|', $params); $obj = new stdClass(); foreach ($a as $p) { $a2 = explode('=', $p); if (!empty($a2) && count($a2) == 2) { $obj->{$a2}[0] = json_decode($a2[1]); } } require_once JPATH_SITE . DS . 'plugins' . DS . 'vmshipment' . DS . 'ulozenka' . DS . 'helper.php'; $xml = UlozenkaHelper::getPobocky($obj); $js_adresa = "\n\nvar adresa=new Array();"; $js_oteviraci_doba = "\n\nvar oteviraci_doba=new Array();"; $js_cena = "\n\nvar cena=new Array();"; $js_values = "\n\nvar values=new Array();"; $document = JFactory::getDocument(); $document->addScriptDeclaration("\n" . '//<![CDATA[' . "\n" . "\n\nvar detail_url='" . JURI::root() . "plugins/vmshipment/ulozenka/detail_pobocky.php?id=';\n" . "\n\n\n\t\t\t\tfunction changeUlozenka(id) {\n\t\t\t\t if (typeof jQuery != 'undefined')\n\t\t\t\t\t jQuery('.zasielka_div1').not('#ulozenka_branch_' + id).hide();\n\t\t\t\t\tdocument.getElementById('ulozenka_pobocka').value=id;\n\t\t\t\t\t\n\t\t\t\t\tvar d = document.getElementById('ulozenka_saved'); \n\t\t\t\t\tif (d != null)\n\t\t\t\t\td.value = id; \n\t\t\t\t\t\n\t\t\t\t\tdocument.getElementById('ulozenka_branch_'+id).style.display='block';\n\t\t\t\t\tif (typeof jQuery != 'undefined')\n\t\t\t\t\t{\n\t\t\t\t\t jQuery('#shipment_id_" . $method->virtuemart_shipmentmethod_id . "').click(); \n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\tdocument.getElementById('shipment_id_" . $method->virtuemart_shipmentmethod_id . "').onclick();\n\t\t\t\t\t\n\t\t\t\t\tif (typeof Onepage != 'undefined')\n\t\t\t\t\tOnepage.changeTextOnePage3();\n\t\t\t\t\t\n\t\t\t\t};\n" . ' var ulozenkaId = null; var ulozenkaIndex = null; var ulozenkaVmId = ' . $method->virtuemart_shipmentmethod_id . '; var lastVmOpt = \'\'; function saveUlozenka() { var dx = document.getElementsByName(\'virtuemart_shipmentmethod_id\');
public static function getDataPobocky(&$params, $id) { $ret = new stdClass(); if (empty(self::$pobocky_cache)) { $pobocky = self::getPobocky($params); self::$pobocky_cache = $pobocky; } else { $pobocky = self::$pobocky_cache; } if (!empty($pobocky->pobocky)) { foreach ($pobocky->pobocky as $p) { if ($p->id == $id) { $arr = (array) $p; foreach ($arr as $key => $val) { $ret->{$key} = $val; } return $ret; } } } return $ret; }
function fetchElement($name, $value, &$node, $control_name) { $db = JFactory::getDBO(); $cid = JRequest::getVar('cid'); $q = 'select shipment_params from #__virtuemart_shipmentmethods where shipment_element = \'ulozenka\' '; if (!empty($cid)) { $cid = (int) $cid[0]; $q .= ' and virtuemart_shipmentmethod_id = ' . $cid; } $db->setQuery($q); $params = $db->loadResult(); $e = $db->getErrorMsg(); if (!empty($e)) { die($e); } $err = true; if (empty($params)) { $err = true; } else { $a = explode('|', $params); $obj = new stdClass(); foreach ($a as $p) { $a2 = explode('=', $p); if (!empty($a2) && count($a2) == 2) { $obj->{$a2}[0] = json_decode($a2[1]); } } require_once JPATH_SITE . DS . 'plugins' . DS . 'vmshipment' . DS . 'ulozenka' . DS . 'helper.php'; $xml = UlozenkaHelper::getPobocky($obj, false); if (!empty($xml->error)) { return $xml->error; } if (!empty($xml)) { if (isset($xml->body)) { $html = ' <tr> <td colspan="4"> <center><span style="color:red;font-weight:bold;">' . $xml->body->div . '</span></center> </td> </tr>'; } $k = 1; foreach ($xml->pobocky as $p) { $err = false; $enabled_const = 'enabled' . $p->id; $parcel_price = 'parcelprice' . $p->id; $dobierka_price = 'codprice' . $p->id; if (empty($obj->pobocky->{$parcel_price})) { $obj->pobocky->{$parcel_price} = $p->prices->parcel; } if (empty($obj->pobocky->{$dobierka_price})) { $obj->pobocky->{$dobierka_price} = $p->prices->cashOnDelivery; } //var_dump($obj->pobocky->enabled6); die(); //'ULOZENKA_'.strtoupper((string)$p->zkratka).'_ENABLED'; $price_const = 'ULOZENKA_' . strtoupper((string) $p->zkratka) . '_PRICE'; if (!empty($obj->pobocky->{$enabled_const})) { $enabled = "checked=\"checked\""; } else { $enabled = ""; } $price = defined($price_const) ? constant($price_const) : '0'; $html .= "<tr class=\"row{$k}\"><td colspan=\" width=\"25%\"><b>" . $p->nazev; if (!empty($p->partner)) { $html .= ' (Partner) '; } $html .= "</b>" . '</td><td width="25%" rowspan="2">' . $p->provoz . '</td><td width="25%" rowspan="2">'; if (empty($p->aktiv)) { $enabled = ' disabled="disabled" '; } if (isset($obj->partners)) { if (empty($obj->partners) && !empty($p->partner)) { $enabled = ' disabled="disabled" '; } } $html .= 'Povolit: <input class="inputbox" type="checkbox" name="params[' . $name . '][' . $enabled_const . ']" ' . $enabled . ' value="1" />' . '</td><td width="30%" rowspan="2">' . 'Cena za dopravu (parcel) (' . $p->prices->parcel . ' ' . $p->prices->currency . '): ' . '<input class="inputbox" type="text" name="params[' . $name . '][' . $parcel_price . ']" value="' . $obj->pobocky->{$parcel_price} . '" />' . 'Priplatek za dopravu (dobirka) (' . $p->prices->cashOnDelivery . ' ' . $p->prices->currency . '): ' . '<input class="inputbox" type="text" name="params[' . $name . '][' . $dobierka_price . ']" value="' . $obj->pobocky->{$dobierka_price} . '" />' . "</td></tr>\n"; $html .= "<tr class=\"row{$k}\"><td colspan=\" width=\"30%\">" . $p->ulice . "<br />\n" . $p->obec . "<br />\n" . $p->psc . "</td></tr>\n"; $pobocky_zkratky[] = strtoupper((string) $p->zkratka); $k = abs($k - 1); } } if (!$err) { if (!empty($html)) { return $html; } } //return '<input type="text" name="params[' . $name . ']" id="params' . $name . '" value="' . $value . '" class="text_area" size="50">'; } if ($err) { return 'Nastavte kluc, a ID obchodu kliknite ulozit a nasledne sa zobrazia pobocky pre ktore je mozne nastavit cenu.'; } }