/** * Reset all default checkboxes when setting a new address as default * @param mixed * @param object * @return mixed * @link http://www.contao.org/callback.html#save_callback */ public function updateDefault($varValue, $dc) { if ($varValue == '1' && $dc->activeRecord->{$dc->field} != $varValue) { \Database::getInstance()->prepare("\n UPDATE " . Address::getTable() . " SET {$dc->field}='' WHERE pid=? AND ptable=? AND store_id=?\n ")->execute($dc->activeRecord->pid, $dc->activeRecord->ptable, $dc->activeRecord->store_id); } return $varValue; }
/** * save_callback to sort attribute wizard fields by legend * * @param mixed $varValue * * @return string */ public function save($varValue) { $this->loadDataContainer(\Isotope\Model\Address::getTable()); $arrFields = deserialize($varValue); if (empty($arrFields) || !is_array($arrFields)) { return $varValue; } $arrValues = array(); foreach (array_values($arrFields) as $pos => $arrConfig) { $arrConfig['position'] = $pos; $arrValues[$arrConfig['name']] = $arrConfig; } return serialize($arrValues); }
\Isotope\Model\Attribute::registerModelType('upload', 'Isotope\\Model\\Attribute\\Upload'); /** * Notification Center notification types */ $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['recipients'] = array('recipient_email'); $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['attachment_tokens'] = array('form_*', 'document'); $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_text'] = array('uniqid', 'order_status', 'order_status_old', 'order_status_id', 'order_status_id_old', 'recipient_email', 'order_id', 'order_items', 'order_products', 'order_subtotal', 'order_total', 'document_number', 'cart_html', 'cart_text', 'document', 'billing_address', 'billing_address_*', 'shipping_address', 'shipping_address_*', 'form_*', 'payment_id', 'payment_label', 'payment_note', 'shipping_id', 'shipping_label', 'shipping_note', 'config_*', 'member_*'); $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_subject'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_text']; $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_html'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_text']; $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_replyTo'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['recipients']; $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_recipient_cc'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['recipients']; $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_recipient_bcc'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['recipients']; /** * Models */ $GLOBALS['TL_MODELS'][\Isotope\Model\Address::getTable()] = 'Isotope\\Model\\Address'; $GLOBALS['TL_MODELS'][\Isotope\Model\Attribute::getTable()] = 'Isotope\\Model\\Attribute'; $GLOBALS['TL_MODELS'][\Isotope\Model\BasePrice::getTable()] = 'Isotope\\Model\\BasePrice'; $GLOBALS['TL_MODELS'][\Isotope\Model\Config::getTable()] = 'Isotope\\Model\\Config'; $GLOBALS['TL_MODELS'][\Isotope\Model\Document::getTable()] = 'Isotope\\Model\\Document'; $GLOBALS['TL_MODELS'][\Isotope\Model\Download::getTable()] = 'Isotope\\Model\\Download'; $GLOBALS['TL_MODELS'][\Isotope\Model\Gallery::getTable()] = 'Isotope\\Model\\Gallery'; $GLOBALS['TL_MODELS'][\Isotope\Model\Group::getTable()] = 'Isotope\\Model\\Group'; $GLOBALS['TL_MODELS'][\Isotope\Model\Label::getTable()] = 'Isotope\\Model\\Label'; $GLOBALS['TL_MODELS'][\Isotope\Model\OrderStatus::getTable()] = 'Isotope\\Model\\OrderStatus'; $GLOBALS['TL_MODELS'][\Isotope\Model\Payment::getTable()] = 'Isotope\\Model\\Payment'; $GLOBALS['TL_MODELS'][\Isotope\Model\Product::getTable()] = 'Isotope\\Model\\Product'; $GLOBALS['TL_MODELS'][\Isotope\Model\ProductCategory::getTable()] = 'Isotope\\Model\\ProductCategory'; $GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollection::getTable()] = 'Isotope\\Model\\ProductCollection'; $GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionDownload::getTable()] = 'Isotope\\Model\\ProductCollectionDownload'; $GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionItem::getTable()] = 'Isotope\\Model\\ProductCollectionItem';
/** * Also delete child table records when dropping this collection * @return integer */ public function delete() { $this->ensureNotLocked(); // !HOOK: additional functionality when deleting a collection if (isset($GLOBALS['ISO_HOOKS']['deleteCollection']) && is_array($GLOBALS['ISO_HOOKS']['deleteCollection'])) { foreach ($GLOBALS['ISO_HOOKS']['deleteCollection'] as $callback) { $objCallback = \System::importStatic($callback[0]); $blnRemove = $objCallback->{$callback}[1]($this); if ($blnRemove === false) { return 0; } } } $intPid = $this->id; $intAffectedRows = parent::delete(); if ($intAffectedRows > 0 && $intPid > 0) { \Database::getInstance()->query("DELETE FROM " . \Isotope\Model\ProductCollectionItem::getTable() . " WHERE pid={$intPid}"); \Database::getInstance()->query("DELETE FROM " . \Isotope\Model\Address::getTable() . " WHERE ptable='" . static::$strTable . "' AND pid={$intPid}"); } $this->arrCache = array(); $this->arrItems = null; $this->arrSurcharges = null; return $intAffectedRows; }
/** * Edit an address record. Based on the PersonalData core module * @param integer * @return void */ protected function edit($intAddressId = 0) { $table = Address::getTable(); \System::loadLanguageFile(\MemberModel::getTable()); $this->Template = new \Isotope\Template($this->memberTpl); $this->Template->hasError = false; $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['saveData']); if ($intAddressId === 0) { $objAddress = Address::createForMember(\FrontendUser::getInstance()->id); } else { $objAddress = Address::findOneForMember($intAddressId, \FrontendUser::getInstance()->id); } if (null === $objAddress) { global $objPage; \Controller::redirect(\Controller::generateFrontendUrl($objPage->row())); } $objForm = new Form($table . '_' . $this->id, 'POST', function ($objForm) { return \Input::post('FORM_SUBMIT') === $objForm->getFormId(); }, (bool) $this->tableless); $objForm->bindModel($objAddress); // Add form fields and modify for the address book $arrFields = $this->arrFields; $objForm->addFieldsFromDca($table, function ($strName, &$arrDca) use($arrFields) { if (!in_array($strName, $arrFields) || !$arrDca['eval']['feEditable']) { return false; } // Map checkboxWizard to regular checkbox widget if ($arrDca['inputType'] == 'checkboxWizard') { $arrDca['inputType'] = 'checkbox'; } // Special field "country" if ($strName == 'country') { $arrCountries = array_merge(Isotope::getConfig()->getBillingCountries(), Isotope::getConfig()->getShippingCountries()); $arrDca['reference'] = $arrDca['options']; $arrDca['options'] = array_values(array_intersect(array_keys($arrDca['options']), $arrCountries)); $arrDca['default'] = Isotope::getConfig()->billing_country; } return true; }); if ($objForm->isSubmitted()) { if ($objForm->validate()) { $objAddress->save(); // Call onsubmit_callback if (is_array($GLOBALS['TL_DCA'][$table]['config']['onsubmit_callback'])) { foreach ($GLOBALS['TL_DCA'][$table]['config']['onsubmit_callback'] as $callback) { $objCallback = \System::importStatic($callback[0]); $objCallback->{$callback}[1]($objAddress); } } global $objPage; \Controller::redirect(\Controller::generateFrontendUrl($objPage->row())); } else { $this->Template->hasError = true; } } $objForm->addToTemplate($this->Template); // Add groups $arrGroups = array(); foreach ($objForm->getFormFields() as $strName => $arrConfig) { if ($arrConfig['feGroup'] != '') { $arrGroups[$arrConfig['feGroup']][$strName] = $objForm->getWidget($strName)->parse(); } } foreach ($arrGroups as $k => $v) { $this->Template->{$k} = $v; } $this->Template->addressDetails = $GLOBALS['TL_LANG'][$table]['addressDetails']; $this->Template->contactDetails = $GLOBALS['TL_LANG'][$table]['contactDetails']; $this->Template->personalData = $GLOBALS['TL_LANG'][$table]['personalData']; $this->Template->loginDetails = $GLOBALS['TL_LANG'][$table]['loginDetails']; }
/** * Mark existing addresses as not default if the new address is default * * @param Address $objAddress */ protected function updateDefaultAddress(Address $objAddress) { $arrSet = array(); if ($objAddress->isDefaultBilling) { $arrSet['isDefaultBilling'] = ''; } if ($objAddress->isDefaultShipping) { $arrSet['isDefaultShipping'] = ''; } if (!empty($arrSet)) { // @todo restore foratting when #6623 is fixed in Contao core \Database::getInstance()->prepare("UPDATE " . $objAddress->getTable() . " %s WHERE pid=? AND ptable=? AND store_id=? AND id!=?")->set($arrSet)->execute($this->member, \MemberModel::getTable(), $this->store_id, $objAddress->id); } }
/** * Generate address details amd return it as string * @param Address * @return string */ protected function generateAddressData(Address $objAddress = null) { if (null === $objAddress) { return '<div class="tl_gerror">No address data available.</div>'; } \System::loadLanguageFile($objAddress->getTable()); $this->loadDataContainer($objAddress->getTable()); $strBuffer = ' <div> <table cellpadding="0" cellspacing="0" class="tl_show" summary="Table lists all details of an entry" style="width:650px"> <tbody>'; $i = 0; foreach ($GLOBALS['TL_DCA'][$objAddress->getTable()]['fields'] as $k => $v) { if (!isset($objAddress->{$k})) { continue; } $v = $objAddress->{$k}; $strClass = ++$i % 2 ? '' : ' class="tl_bg"'; $strBuffer .= ' <tr> <td' . $strClass . ' style="vertical-align:top"><span class="tl_label">' . Format::dcaLabel($objAddress->getTable(), $k) . ': </span></td> <td' . $strClass . '>' . Format::dcaValue($objAddress->getTable(), $k, $v) . '</td> </tr>'; } $strBuffer .= ' </tbody></table> </div>'; return $strBuffer; }
<?php /** * Isotope eCommerce for Contao Open Source CMS * * Copyright (C) 2009-2014 terminal42 gmbh & Isotope eCommerce Workgroup * * @package Isotope * @link http://isotopeecommerce.org * @license http://opensource.org/licenses/lgpl-3.0.html */ /** * Load tl_iso_product data container and language files */ $this->loadDataContainer('tl_iso_product'); \System::loadLanguageFile('tl_iso_product'); /** * Table tl_iso_product_collection */ $GLOBALS['TL_DCA']['tl_iso_product_collection'] = array('config' => array('dataContainer' => 'Table', 'enableVersioning' => false, 'ctable' => array(\Isotope\Model\ProductCollectionItem::getTable(), \Isotope\Model\ProductCollectionSurcharge::getTable(), \Isotope\Model\Address::getTable()), 'closed' => true, 'notDeletable' => \Input::get('act') == 'select', 'onload_callback' => array(array('Isotope\\Backend\\ProductCollection\\Callback', 'checkPermission')), 'onsubmit_callback' => array(array('Isotope\\Backend\\ProductCollection\\Callback', 'executeSaveHook')), 'sql' => array('keys' => array('id' => 'primary', 'uniqid' => 'unique', 'member,store_id,type' => 'index', 'uniqid,store_id,type' => 'index', 'source_collection_id,type' => 'index'))), 'list' => array('sorting' => array('mode' => 2, 'fields' => array('locked DESC'), 'panelLayout' => 'filter;sort,search,limit', 'filter' => array(array('type=?', 'order'), array('order_status>?', '0'), array("locked!=?", ''))), 'label' => array('fields' => array('document_number', 'locked', 'billing_address_id', 'total', 'order_status'), 'showColumns' => true, 'label_callback' => array('Isotope\\Backend\\ProductCollection\\Callback', 'getOrderLabel')), 'global_operations' => array('all' => array('label' => &$GLOBALS['TL_LANG']['MSC']['all'], 'href' => 'act=select', 'class' => 'header_edit_all', 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"')), 'operations' => array('edit' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['edit'], 'href' => 'act=edit', 'icon' => 'edit.gif'), 'delete' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['delete'], 'href' => 'act=delete', 'icon' => 'delete.gif', 'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'), 'show' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['show'], 'href' => 'act=show', 'icon' => 'show.gif'), 'payment' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['payment'], 'href' => 'key=payment', 'icon' => 'system/modules/isotope/assets/images/money-coin.png', 'button_callback' => array('\\Isotope\\Backend\\ProductCollection\\Callback', 'paymentButton')), 'shipping' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['shipping'], 'href' => 'key=shipping', 'icon' => 'system/modules/isotope/assets/images/box-label.png', 'button_callback' => array('\\Isotope\\Backend\\ProductCollection\\Callback', 'shippingButton')), 'print_document' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['print_document'], 'href' => 'key=print_document', 'icon' => 'system/modules/isotope/assets/images/document-pdf-text.png'))), 'palettes' => array('default' => '{status_legend},order_status,date_paid,date_shipped;{details_legend},details,notes;{email_legend:hide},email_data;{billing_address_legend:hide},billing_address_data;{shipping_address_legend:hide},shipping_address_data'), 'fields' => array('id' => array('sql' => "int(10) unsigned NOT NULL auto_increment"), 'tstamp' => array('sql' => "int(10) unsigned NOT NULL default '0'"), 'type' => array('eval' => array('doNotShow' => true), 'sql' => "varchar(32) NOT NULL default ''"), 'member' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['member'], 'foreignKey' => "tl_member.CONCAT(firstname, ' ', lastname)", 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'locked' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['locked'], 'flag' => 8, 'filter' => true, 'sorting' => true, 'eval' => array('rgxp' => 'date'), 'sql' => "varchar(10) NOT NULL default ''"), 'store_id' => array('eval' => array('doNotShow' => true), 'sql' => "int(2) unsigned NOT NULL default '0'"), 'settings' => array('eval' => array('doNotShow' => true), 'sql' => "blob NULL"), 'checkout_info' => array('eval' => array('doNotShow' => true), 'sql' => "blob NULL"), 'payment_data' => array('eval' => array('doNotShow' => true), 'sql' => "blob NULL"), 'shipping_data' => array('eval' => array('doNotShow' => true), 'sql' => "blob NULL"), 'source_collection_id' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['source_collection_id'], 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy', 'table' => 'tl_iso_product_collection')), 'document_number' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['document_number'], 'search' => true, 'sorting' => true, 'sql' => "varchar(64) NOT NULL default ''"), 'uniqid' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['uniqid'], 'search' => true, 'sql' => "varchar(64) NULL"), 'order_status' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['order_status'], 'exclude' => true, 'filter' => true, 'sorting' => true, 'inputType' => 'select', 'foreignKey' => \Isotope\Model\OrderStatus::getTable() . '.name', 'options_callback' => array('\\Isotope\\Backend', 'getOrderStatus'), 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy'), 'save_callback' => array(array('Isotope\\Backend\\ProductCollection\\Callback', 'updateOrderStatus'))), 'date_paid' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['date_paid'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'datim', 'datepicker' => method_exists($this, 'getDatePickerString') ? $this->getDatePickerString() : true, 'tl_class' => 'w50 wizard'), 'sql' => "varchar(10) NOT NULL default ''"), 'date_shipped' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['date_shipped'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'date', 'datepicker' => method_exists($this, 'getDatePickerString') ? $this->getDatePickerString() : true, 'tl_class' => 'w50 wizard'), 'sql' => "varchar(10) NOT NULL default ''"), 'config_id' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['config_id'], 'foreignKey' => \Isotope\Model\Config::getTable() . '.name', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'payment_id' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['payment_id'], 'filter' => true, 'foreignKey' => \Isotope\Model\Payment::getTable() . '.name', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'shipping_id' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['shipping_id'], 'filter' => true, 'foreignKey' => \Isotope\Model\Shipping::getTable() . '.name', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'billing_address_id' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['billing_address_id'], 'foreignKey' => \Isotope\Model\Address::getTable() . '.label', 'eval' => array('doNotShow' => true), 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'shipping_address_id' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['shipping_address_id'], 'foreignKey' => \Isotope\Model\Address::getTable() . '.label', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'details' => array('input_field_callback' => array('Isotope\\Backend\\ProductCollection\\Callback', 'generateOrderDetails'), 'eval' => array('doNotShow' => true)), 'subtotal' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['subtotal'], 'sql' => "decimal(12,2) NOT NULL default '0.00'"), 'tax_free_subtotal' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['tax_free_subtotal'], 'sql' => "decimal(12,2) NOT NULL default '0.00'"), 'total' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['total'], 'sorting' => true, 'sql' => "decimal(12,2) NOT NULL default '0.00'"), 'tax_free_total' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['tax_free_total'], 'sql' => "decimal(12,2) NOT NULL default '0.00'"), 'currency' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['currency'], 'sql' => "varchar(4) NOT NULL default ''"), 'language' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['language'], 'sql' => "varchar(5) NOT NULL default ''"), 'notes' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['notes'], 'exclude' => true, 'inputType' => 'textarea', 'eval' => array('style' => 'height:80px;'), 'sql' => "text NULL"), 'email_data' => array('input_field_callback' => array('Isotope\\Backend\\ProductCollection\\Callback', 'generateEmailData'), 'eval' => array('doNotShow' => true)), 'billing_address_data' => array('input_field_callback' => array('Isotope\\Backend\\ProductCollection\\Callback', 'generateBillingAddressData'), 'eval' => array('doNotShow' => true)), 'shipping_address_data' => array('input_field_callback' => array('Isotope\\Backend\\ProductCollection\\Callback', 'generateShippingAddressData'), 'eval' => array('doNotShow' => true))));
/** * Get widget objects for address fields * @return \Widget[] */ protected function getWidgets() { if (null === $this->arrWidgets) { $this->arrWidgets = array(); $objAddress = $this->getDefaultAddress(); foreach ($this->getAddressFields() as $field) { // Do not use reference, otherwise the billing address fields would affect shipping address fields $arrData = $GLOBALS['TL_DCA'][\Isotope\Model\Address::getTable()]['fields'][$field['value']]; if (!is_array($arrData) || !$arrData['eval']['feEditable'] || !$field['enabled'] || $arrData['eval']['membersOnly'] && FE_USER_LOGGED_IN !== true) { continue; } $strClass = $GLOBALS['TL_FFL'][$arrData['inputType']]; // Continue if the class is not defined if ($strClass == '' || !class_exists($strClass)) { continue; } // Special field "country" if ($field['value'] == 'country') { $arrCountries = $this->getAddressCountries(); $arrData['reference'] = $arrData['options']; $arrData['options'] = array_values(array_intersect(array_keys($arrData['options']), $arrCountries)); } elseif (strlen($arrData['eval']['conditionField'])) { $arrData['eval']['conditionField'] = $this->getStepClass() . '_' . $arrData['eval']['conditionField']; } $objWidget = new $strClass($strClass::getAttributesFromDca($arrData, $this->getStepClass() . '_' . $field['value'], $objAddress->{$field['value']})); $objWidget->mandatory = $field['mandatory'] ? true : false; $objWidget->required = $objWidget->mandatory; $objWidget->tableless = $this->objModule->tableless; $objWidget->storeValues = true; $this->arrWidgets[$field['value']] = $objWidget; } } return $this->arrWidgets; }
/** * Generate the module */ protected function compile() { $this->Template->hasError = false; $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['saveAddressButton']); $table = Address::getTable(); \System::loadLanguageFile($table); \Controller::loadDataContainer($table); // Call onload_callback (e.g. to check permissions) if (is_array($GLOBALS['TL_DCA'][$table]['config']['onload_callback'])) { foreach ($GLOBALS['TL_DCA'][$table]['config']['onload_callback'] as $callback) { $objCallback = \System::importStatic($callback[0]); $objCallback->{$callback}[1](); } } $arrFields = $this->iso_addressFields; $useBilling = in_array('billing', $this->iso_address); $objAddress = $this->getDefaultAddress($useBilling); $objForm = new Form('iso_cart_address_' . $this->id, 'POST', function ($objHaste) { /** @type Form $objHaste */ return \Input::post('FORM_SUBMIT') === $objHaste->getFormId(); }, (bool) $this->tableless); $objForm->bindModel($objAddress); // Add form fields $objForm->addFieldsFromDca($table, function ($strName, &$arrDca) use($arrFields, $useBilling) { if (!in_array($strName, $arrFields) || !$arrDca['eval']['feEditable'] || $arrDca['eval']['membersOnly'] && FE_USER_LOGGED_IN !== true) { return false; } // Special field "country" if ($strName == 'country') { if ($useBilling) { $arrCountries = Isotope::getConfig()->getBillingCountries(); $arrDca['default'] = Isotope::getConfig()->billing_country; } else { $arrCountries = Isotope::getConfig()->getShippingCountries(); $arrDca['default'] = Isotope::getConfig()->shipping_country; } $arrDca['reference'] = $arrDca['options']; $arrDca['options'] = array_values(array_intersect(array_keys($arrDca['options']), $arrCountries)); } return true; }); $objCart = Isotope::getCart(); // Save the data if ($objForm->validate()) { if (!$objCart->id) { $objCart->save(); } $objAddress->tstamp = time(); $objAddress->pid = $objCart->id; $objAddress->save(); // Call onsubmit_callback if (is_array($GLOBALS['TL_DCA'][$table]['config']['onsubmit_callback'])) { foreach ($GLOBALS['TL_DCA'][$table]['config']['onsubmit_callback'] as $callback) { $objCallback = \System::importStatic($callback[0]); $objCallback->{$callback}[1]($objAddress); } } // Set the billing address if ($useBilling) { $objCart->setBillingAddress($objAddress); } // Set the shipping address if (in_array('shipping', $this->iso_address)) { $objCart->setShippingAddress($objAddress); } $this->jumpToOrReload($this->jumpTo); } $objForm->addToTemplate($this->Template); // Predefine the group order (other groups will be appended automatically) $arrGroups = array(); $categories = array('personal' => array(), 'address' => array(), 'contact' => array(), 'login' => array(), 'profile' => array()); foreach ($objForm->getFormFields() as $strName => $arrConfig) { if ($arrConfig['feGroup'] != '') { $arrGroups[$arrConfig['feGroup']][$strName] = $objForm->getWidget($strName)->parse(); } } foreach ($arrGroups as $k => $v) { $this->Template->{$k} = $v; // backwards compatibility $key = $k . ($k == 'personal' ? 'Data' : 'Details'); $categories[$GLOBALS['TL_LANG']['tl_member'][$key]] = $v; } $this->Template->categories = $categories; $this->Template->addressDetails = $GLOBALS['TL_LANG'][$table]['addressDetails']; $this->Template->contactDetails = $GLOBALS['TL_LANG'][$table]['contactDetails']; $this->Template->personalData = $GLOBALS['TL_LANG'][$table]['personalData']; $this->Template->loginDetails = $GLOBALS['TL_LANG'][$table]['loginDetails']; }
<?php /** * Isotope eCommerce for Contao Open Source CMS * * Copyright (C) 2009-2014 terminal42 gmbh & Isotope eCommerce Workgroup * * @package Isotope * @link http://isotopeecommerce.org * @license http://opensource.org/licenses/lgpl-3.0.html */ /** * Add a child table to tl_member */ $GLOBALS['TL_DCA']['tl_member']['config']['ctable'][] = \Isotope\Model\Address::getTable(); $GLOBALS['TL_DCA']['tl_member']['config']['ondelete_callback'][] = array('\\Isotope\\Backend\\Member\\Callback', 'deleteMemberCart'); /** * Add a global operation to tl_member */ $GLOBALS['TL_DCA']['tl_member']['list']['operations']['address_book'] = array('label' => &$GLOBALS['TL_LANG']['tl_member']['address_book'], 'href' => 'table=' . \Isotope\Model\Address::getTable(), 'icon' => 'system/modules/isotope/assets/images/cards-address.png'); /** * Force the "country" field to be mandatory */ $GLOBALS['TL_DCA']['tl_member']['fields']['country']['eval']['mandatory'] = true;
$GLOBALS['TL_DCA']['tl_module']['fields']['iso_enableLimit'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_enableLimit'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('submitOnChange' => true, 'tl_class' => 'clr w50 m12'), 'sql' => "char(1) NOT NULL default ''"); $GLOBALS['TL_DCA']['tl_module']['fields']['iso_perPage'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_perPage'], 'exclude' => true, 'default' => '8,12,32,64', 'inputType' => 'text', 'eval' => array('mandatory' => true, 'maxlength' => 64, 'rgxp' => 'extnd', 'tl_class' => 'w50'), 'sql' => "varchar(64) NOT NULL default ''"); $GLOBALS['TL_DCA']['tl_module']['fields']['iso_cart_jumpTo'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_cart_jumpTo'], 'exclude' => true, 'inputType' => 'pageTree', 'foreignKey' => 'tl_page.title', 'eval' => array('fieldType' => 'radio', 'tl_class' => 'clr'), 'explanation' => 'jumpTo', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')); $GLOBALS['TL_DCA']['tl_module']['fields']['iso_checkout_jumpTo'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_checkout_jumpTo'], 'exclude' => true, 'inputType' => 'pageTree', 'foreignKey' => 'tl_page.title', 'eval' => array('fieldType' => 'radio', 'tl_class' => 'clr'), 'explanation' => 'jumpTo', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')); $GLOBALS['TL_DCA']['tl_module']['fields']['iso_listingSortField'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_listingSortField'], 'exclude' => true, 'inputType' => 'select', 'options_callback' => array('Isotope\\Backend\\Module\\Callback', 'getSortingFields'), 'eval' => array('includeBlankOption' => true, 'tl_class' => 'clr w50'), 'sql' => "varchar(255) NOT NULL default ''", 'save_callback' => array(array('Isotope\\Backend', 'truncateProductCache'))); $GLOBALS['TL_DCA']['tl_module']['fields']['iso_listingSortDirection'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_listingSortDirection'], 'exclude' => true, 'default' => 'DESC', 'inputType' => 'select', 'options' => array('DESC', 'ASC'), 'reference' => &$GLOBALS['TL_LANG']['tl_module']['sortingDirection'], 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(8) NOT NULL default ''"); $GLOBALS['TL_DCA']['tl_module']['fields']['iso_buttons'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_buttons'], 'exclude' => true, 'inputType' => 'checkboxWizard', 'default' => array('add_to_cart'), 'options_callback' => array('Isotope\\Backend\\Module\\Callback', 'getButtons'), 'eval' => array('multiple' => true, 'tl_class' => 'clr'), 'sql' => "blob NULL"); $GLOBALS['TL_DCA']['tl_module']['fields']['iso_related_categories'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_related_categories'], 'exclude' => true, 'inputType' => 'checkboxWizard', 'foreignKey' => \Isotope\Model\RelatedCategory::getTable() . '.name', 'eval' => array('mandatory' => true, 'multiple' => true, 'tl_class' => 'clr'), 'sql' => "blob NULL", 'relation' => array('type' => 'hasMany', 'load' => 'lazy')); $GLOBALS['TL_DCA']['tl_module']['fields']['iso_includeMessages'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_includeMessages'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('doNotCopy' => true, 'tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"); $GLOBALS['TL_DCA']['tl_module']['fields']['iso_continueShopping'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_continueShopping'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"); $GLOBALS['TL_DCA']['tl_module']['fields']['iso_address'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_address'], 'exclude' => true, 'inputType' => 'checkbox', 'options' => array('billing', 'shipping'), 'reference' => &$GLOBALS['TL_LANG']['tl_module']['iso_address'], 'eval' => array('mandatory' => true, 'multiple' => true), 'sql' => "blob NULL"); $GLOBALS['TL_DCA']['tl_module']['fields']['iso_addressFields'] = array('label' => &$GLOBALS['TL_LANG']['tl_module']['iso_addressFields'], 'exclude' => true, 'inputType' => 'checkboxWizard', 'options_callback' => function () { \Controller::loadDataContainer(\Isotope\Model\Address::getTable()); \System::loadLanguageFile(\Isotope\Model\Address::getTable()); $arrOptions = array(); $arrDCA =& $GLOBALS['TL_DCA'][\Isotope\Model\Address::getTable()]['fields']; foreach ($arrDCA as $k => $arrField) { if (!$arrField['eval']['feEditable']) { continue; } $arrOptions[$k] = $arrField['label'][0]; } return $arrOptions; }, 'eval' => array('mandatory' => true, 'multiple' => true, 'tl_class' => 'clr'), 'sql' => "blob NULL"); $GLOBALS['TL_DCA']['tl_module']['fields']['iso_productcache'] = array('sql' => "blob NULL"); /** * Limit notification choices */ $GLOBALS['TL_DCA']['tl_module']['fields']['nc_notification']['eval']['ncNotificationChoices']['iso_checkout'] = array('iso_order_status_change'); $GLOBALS['TL_DCA']['tl_module']['fields']['nc_notification']['eval']['ncNotificationChoices']['iso_checkoutmember'] = array('iso_order_status_change'); $GLOBALS['TL_DCA']['tl_module']['fields']['nc_notification']['eval']['ncNotificationChoices']['iso_checkoutguest'] = array('iso_order_status_change');