Jump to content

CloudCyberSystems

Members
  • Posts

    40
  • Joined

  • Last visited

Profile Information

  • Location
    Barry
  • Activity
    User/Merchant

CloudCyberSystems's Achievements

Newbie

Newbie (1/14)

2

Reputation

4

Community Answers

  1. Dear lord..... thanks for spotting that Ok its updating now but! if i fill one of the 4 required fields in it does not say required fields are missing. also its putting empty values into the database. public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $xml_service_name=Tools::getValue('xml_service_name'); $xml_service_customer_code=Tools::getValue('xml_service_customer_code'); $xml_service_user_id=Tools::getValue('xml_service_user_id'); $xml_service_login_key=Tools::getValue('xml_service_login_key'); if(Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'xmlapi` (`xml_service_name`, `xml_service_customer_code`, `xml_service_user_id`,`xml_service_login_key`) VALUES ("'.$xml_service_name.'","'.$xml_service_customer_code.'","'.$xml_service_user_id.'","'.$xml_service_login_key.'")')) { $output .= $this->displayConfirmation($this->l('Service Added.')); } else { $output .= $this->displayError($this->l('Error updating database.')); $output .= $this->displayError($this->l("Customer Code: ".$xml_service_customer_code)); } } return $output.$this->renderForm(); } protected function renderForm() { $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); $fields_form = array( 'tinymce' => true, 'legend' => array( 'title' => $this->l('Add XML Service'), ), 'input' => array( 'xml_service_id' => array( 'type' => 'hidden', 'name' => 'xml_service_id' ), 'xml_service_name' => array( 'type' => 'text', 'label' => $this->l('Service Name'), 'lang' => true, 'name' => 'xml_service_name', 'size' => '15', 'class' => 'rte', 'required' => true ), 'xml_service_customer_code' => array( 'type' => 'text', 'label' => $this->l('Customer Code'), 'lang' => true, 'name' => 'xml_service_customer_code', 'size' => '15', 'class' => 'rte', 'required' => true ), 'xml_service_customer_user_id' => array( 'type' => 'text', 'label' => $this->l('User ID'), 'lang' => true, 'name' => 'xml_service_customer_user_id', 'size' => '15', 'class' => 'rte', 'required' => true ), 'xml_service_customer_login_key' => array( 'type' => 'text', 'label' => $this->l('Login Key'), 'lang' => true, 'name' => 'xml_service_customer_login_key', 'size' => '15', 'class' => 'rte', 'required' => true ), ), 'submit' => array( 'title' => $this->l('Add Service'), ), 'buttons' => array( array( 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules'), 'title' => $this->l('Back to list'), 'icon' => 'process-icon-back' ) ) ); if (Shop::isFeatureActive() && Tools::getValue('xml_service_id') && Tools::getValue('xml_service_name') && Tools::getValue('xml_service_user_id') && Tools::getValue('xml_service_login_key') == false) { $fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso_theme' ); } $helper = new HelperForm(); $helper->module = $this; $helper->name_controller = $this->name; $helper->identifier = $this->identifier; $helper->token = Tools::getAdminTokenLite('AdminModules'); foreach (Language::getLanguages(false) as $lang) $helper->languages[] = array( 'id_lang' => $lang['id_lang'], 'iso_code' => $lang['iso_code'], 'name' => $lang['name'], 'is_default' => ($default_lang == $lang['id_lang'] ? 1 : 0) ); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; $helper->toolbar_scroll = true; $helper->title = $this->displayName; $helper->submit_action = 'submit'.$this->name; $helper->fields_value = $this->getFormValues(); return $helper->generateForm(array(array('form' => $fields_form))); } public function getFormValues() { $fields_value = array(); $xml_service_name = (int)Tools::getValue('xml_service_name'); $xml_service_customer_code = (int)Tools::getValue('xml_service_customer_code'); $xml_service_user_id = (int)Tools::getValue('xml_service_user_id'); $xml_service_login_key = (int)Tools::getValue('xml_service_login_key'); foreach (Language::getLanguages(false) as $lang) if ($xml_service_id) { $info = new InfoBlock((int)$xml_service_id); $fields_value['text'][(int)$lang['id_lang']] = $info->text[(int)$lang['id_lang']]; } else $fields_value['text'][(int)$lang['id_lang']] = Tools::getValue('text_'.(int)$lang['id_lang'], ''); $fields_value['xml_service_name'] = $xml_service_name; $fields_value['xml_service_customer_code'] = $xml_service_customer_code; $fields_value['xml_service_user_id'] = $xml_service_user_id; $fields_value['xml_service_login_key'] = $xml_service_login_key; return $fields_value; }
  2. theres 4 of each here... if(Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'xmlapi` (`xml_service_name`, `xml_service_customer_code`, `xml_service_user_id`,`xml_service_login_key`) VALUES ("","'.$xml_service_name.'","'.$xml_service_customer_code.'","'.$xml_service_user_id.'","'.$xml_service_login_key.'")'))
  3. Ok, so I need to replace that code with code to update the database? This gives me Error updating database. Is there something I'm missing? public function getContent() { $output = null; $xml_service_name=Tools::getValue('xml_service_name'); $xml_service_customer_code=Tools::getValue('xml_service_customer_code'); $xml_service_user_id=Tools::getValue('xml_service_user_id'); $xml_service_login_key=Tools::getValue('xml_service_login_key'); if (Tools::isSubmit('submit'.$this->name)) { if(Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'xmlapi` (`xml_service_name`, `xml_service_customer_code`, `xml_service_user_id`,`xml_service_login_key`) VALUES ("","'.$xml_service_name.'","'.$xml_service_customer_code.'","'.$xml_service_user_id.'","'.$xml_service_login_key.'")')) { $output .= $this->displayConfirmation($this->l('Service Added.')); } else { $output .= $this->displayError($this->l('Error updating database.')); } } return $output.$this->renderForm(); }
  4. Great! all fields are showing now. but when i fill out the form and press save I get Invalid Configuration value public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $xmlapi = strval(Tools::getValue('xml_service_id')); if (!$xmlapi || empty($xmlapi) || !Validate::isGenericName($xmlapi)) $output .= $this->displayError($this->l('Invalid Configuration value')); else { Configuration::updateValue('xml_service_id', $xmlapi); $output .= $this->displayConfirmation($this->l('Settings updated')); } } return $output.$this->renderForm(); } protected function renderForm() { $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); $fields_form = array( 'tinymce' => true, 'legend' => array( 'title' => $this->l('Add XML Service'), ), 'input' => array( 'xml_service_id' => array( 'type' => 'hidden', 'name' => 'xml_service_id' ), 'xml_service_name' => array( 'type' => 'text', 'label' => $this->l('Service Name'), 'lang' => true, 'name' => 'xml_service_name', 'size' => '15', 'class' => 'rte', 'required' => true ), 'xml_service_customer_code' => array( 'type' => 'text', 'label' => $this->l('Customer Code'), 'lang' => true, 'name' => 'xml_service_customer_code', 'size' => '15', 'class' => 'rte', 'required' => true ), 'xml_service_customer_user_id' => array( 'type' => 'text', 'label' => $this->l('User ID'), 'lang' => true, 'name' => 'xml_service_customer_user_id', 'size' => '15', 'class' => 'rte', 'required' => true ), 'xml_service_customer_login_key' => array( 'type' => 'text', 'label' => $this->l('Login Key'), 'lang' => true, 'name' => 'xml_service_customer_login_key', 'size' => '15', 'class' => 'rte', 'required' => true ), ), 'submit' => array( 'title' => $this->l('Add Service'), ), 'buttons' => array( array( 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules'), 'title' => $this->l('Back to list'), 'icon' => 'process-icon-back' ) ) ); if (Shop::isFeatureActive() && Tools::getValue('xml_service_id') && Tools::getValue('xml_service_name') && Tools::getValue('xml_service_user_id`') && Tools::getValue('xml_service_login_key`') == false) { $fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso_theme' ); } $helper = new HelperForm(); $helper->module = $this; $helper->name_controller = $this->name; $helper->identifier = $this->identifier; $helper->token = Tools::getAdminTokenLite('AdminModules'); foreach (Language::getLanguages(false) as $lang) $helper->languages[] = array( 'id_lang' => $lang['id_lang'], 'iso_code' => $lang['iso_code'], 'name' => $lang['name'], 'is_default' => ($default_lang == $lang['id_lang'] ? 1 : 0) ); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; $helper->toolbar_scroll = true; $helper->title = $this->displayName; $helper->submit_action = 'submit'.$this->name; $helper->fields_value = $this->getFormValues(); return $helper->generateForm(array(array('form' => $fields_form)));
  5. The hidden field has been added what i mean is there should be to visible fields now 'input' => array( 'xml_service_id' => array( 'type' => 'hidden', 'name' => 'xml_service_id' ), 'content' => array( 'type' => 'text', 'label' => $this->l('Service Name'), 'lang' => true, 'name' => 'xml_service_name', 'size' => '15', 'class' => 'rte', 'required' => true ), 'content' => array( 'type' => 'text', 'label' => $this->l('Customer Code'), 'lang' => true, 'name' => 'xml_service_customer_code', 'size' => '15', 'class' => 'rte', 'required' => true ), ), Service Name & Customer Code
  6. Thanks for the help rytiz2873, I have modified the code as follows; protected function renderForm() { $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); $fields_form = array( 'tinymce' => true, 'legend' => array( 'title' => $this->l('Add XML Service'), ), 'input' => array( 'xml_service_id' => array( 'type' => 'hidden', 'name' => 'xml_service_id' ), 'content' => array( 'type' => 'text', 'label' => $this->l('Service Name'), 'lang' => true, 'name' => 'xml_service_name', 'size' => '15', 'class' => 'rte', 'required' => true ), 'content' => array( 'type' => 'text', 'label' => $this->l('Customer Code'), 'lang' => true, 'name' => 'xml_service_customer_code', 'size' => '15', 'class' => 'rte', 'required' => true ), ), 'submit' => array( 'title' => $this->l('Add Service'), ), 'buttons' => array( array( 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules'), 'title' => $this->l('Back to list'), 'icon' => 'process-icon-back' ) ) ); if (Shop::isFeatureActive() && Tools::getValue('xml_service_id') && Tools::getValue('xml_service_name') == false) { $fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso_theme' ); } $helper = new HelperForm(); $helper->module = $this; $helper->name_controller = $this->name; $helper->identifier = $this->identifier; $helper->token = Tools::getAdminTokenLite('AdminModules'); foreach (Language::getLanguages(false) as $lang) $helper->languages[] = array( 'id_lang' => $lang['id_lang'], 'iso_code' => $lang['iso_code'], 'name' => $lang['name'], 'is_default' => ($default_lang == $lang['id_lang'] ? 1 : 0) ); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; $helper->toolbar_scroll = true; $helper->title = $this->displayName; $helper->submit_action = 'submit'.$this->name; $helper->fields_value = $this->getFormValues(); return $helper->generateForm(array(array('form' => $fields_form))); } public function getFormValues() { $fields_value = array(); $xml_service_id = (int)Tools::getValue('xml_service_id'); foreach (Language::getLanguages(false) as $lang) if ($xml_service_id) { $info = new InfoBlock((int)$xml_service_id); $fields_value['text'][(int)$lang['id_lang']] = $info->text[(int)$lang['id_lang']]; } else $fields_value['text'][(int)$lang['id_lang']] = Tools::getValue('text_'.(int)$lang['id_lang'], ''); $fields_value['xml_service_id'] = $xml_service_id; return $fields_value; } } But the form is only showing the "Customer Code" text area... not Service Name & Customer Code
  7. Ok so i had a problem installing my module which is now solved. BUT now for some reason i cant get the module form to add records entered into the form to the database. Can someone please point out where i am going wrong. (here is the entire page code <?php if (!defined('_PS_VERSION_')) exit; class XmlApi extends Module { public function __construct() { $this->name = 'xmlapi'; $this->tab = 'administration'; $this->version = '1.0.0'; $this->author = 'Andrew Burston'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Xml API'); $this->description = $this->l('Import/Update Products and send orders to your suppliers!.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('xml_api')) $this->warning = $this->l('No name provided'); } public function install() { /* Config values and register */ $languages = $this->getAvailableLanguages($this->id_shop); $homecat = array(); if (!parent::install() || !$this->installDB() ) return false; return true; } public function installDB() { return Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'xmlapi` ( `xml_service_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `xml_service_customer_code` VARCHAR(255) NOT NULL, `xml_service_user_id` VARCHAR(255) NOT NULL, `xml_service_login_key` VARCHAR(255) NOT NULL, INDEX (`xml_service_id`) ) DEFAULT CHARSET=utf8;'); } public function uninstall() { if (!parent::uninstall() || !$this->uninstallDB() ) return false; return true; } public function uninstallDB() { return Db::getInstance()->execute(' DROP TABLE `'._DB_PREFIX_.'xmlapi`'); } public function getAvailableLanguages($id_shop) { if (version_compare(_PS_VERSION_, '1.5', '>')) $shopLanguages = Language::getLanguages(false, (int)($id_shop)); else $shopLanguages = Language::getLanguages(false); $okLanguages = array(); foreach ($shopLanguages as $language) if ($language['active'] && array_key_exists($language['iso_code'], $this->gMerchantCenterCountries)) $okLanguages[] = $language; return $okLanguages; } public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $xmlapi = strval(Tools::getValue('xml_api')); if (!$xmlapi || empty($xmlapi) || !Validate::isGenericName($xmlapi)) $output .= $this->displayError($this->l('Invalid Configuration value')); else { Configuration::updateValue('xml_api', $xmlapi); $output .= $this->displayConfirmation($this->l('Settings updated')); } } return $output.$this->displayForm(); } public function displayForm() { // Get default language $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); // Init Fields form array $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Add XML Server'), ), 'input' => array( 'xml_service_customer_code' => array( 'type' => 'text', 'label' => $this->l('Customer Code'), 'name' => 'xml_service_customer_code', 'size' => 20, 'required' => false ), 'xml_service_user_id' => array( 'type' => 'text', 'label' => $this->l('User ID'), 'name' => 'xml_service_user_id', 'size' => 20, 'required' => true ), 'xml_service_login_key' => array( 'type' => 'text', 'label' => $this->l('Login Key'), 'name' => 'xml_service_login_key', 'size' => 20, 'required' => true ) ), 'submit' => array( 'title' => $this->l('Save XML Server'), 'class' => 'button' ) ); $helper = new HelperForm(); // Module, token and currentIndex $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; // Language $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; // Title and toolbar $helper->title = $this->displayName; $helper->show_toolbar = true; // false -> remove toolbar $helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $helper->submit_action = 'submit'.$this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules'), ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); // Load current value $helper->fields_value['xml_api'] = Configuration::get('xml_api'); return $helper->generateForm($fields_form); } }
  8. SOLVED! for anyone else having this problem here is the working code public function install() { /* Config values and register */ $languages = $this->getAvailableLanguages($this->id_shop); $homecat = array(); if (!parent::install() || !$this->installDB() ) return false; return true; } public function installDB() { return Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'xmlapi` ( `xml_service_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `xml_service_customer_code` VARCHAR(255) NOT NULL, `xml_service_user_id` VARCHAR(255) NOT NULL, `xml_service_login_key` VARCHAR(255) NOT NULL, INDEX (`xml_service_id`) ) DEFAULT CHARSET=utf8;'); } public function uninstall() { if (!parent::uninstall() || !$this->uninstallDB() ) return false; return true; } public function uninstallDB() { return Db::getInstance()->execute(' DROP TABLE `'._DB_PREFIX_.'xmlapi`'); }
  9. Nope still getting the same error now.... heres my code... Again both (http://www.piliapp.c...l-syntax-check/ http://phpcodechecker.com/) are showing no errors..... public function install() { /* Config values and register */ $languages = $this->getAvailableLanguages($this->id_shop); $homecat = array(); if (!parent::install() || !$this->installDB() ) return false; return true; } public function installDB() { return Db::getInstance()->execute(' CREATE TABLE `'._DB_PREFIX_.'xmlapi` ( `xml_service_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `xml_service_customer_code` VARCHAR(255) NOT NULL, `xml_service_user_id` VARCHAR(255) NOT NULL, `xml_service_login_key` VARCHAR(255) NOT NULL, PRIMARY KEY (`xml_service_id`) ) DEFAULT CHARSET=utf8;'); }
  10. I'm getting The following module(s) could not be installed properly: xmlapi : Here is my install code. Whats wrong with it? public function installDB() { return Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'xmlapi` `xml_service_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `xml_service_customer_code` VARCHAR(255) NOT NULL, `xml_service_user_id` VARCHAR(255) NOT NULL, `xml_service_login_key` VARCHAR(255) NOT NULL, PRIMARY KEY (`xml_service_id`) ) DEFAULT CHARSET=utf8;'); } public function install() { /* Config values and register */ $languages = $this->getAvailableLanguages($this->id_shop); $homecat = array(); if (!parent::install() || !$this->installDB() ) return false; return true; } I've also tried public function install() { /* Config values and register */ $languages = $this->getAvailableLanguages($this->id_shop); $homecat = array(); if (!parent::install() || !$this->installDB() ) return false; return true; } public function installDB() { return Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'xmlapi` `xml_service_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `xml_service_customer_code` VARCHAR(255) NOT NULL, `xml_service_user_id` VARCHAR(255) NOT NULL, `xml_service_login_key` VARCHAR(255) NOT NULL, PRIMARY KEY (`xml_service_id`) ) DEFAULT CHARSET=utf8;'); }
  11. Where are you getting cloud from? I want to use an xml api to up date my WEBSITE, nothing to do with a cloud lol. I want a module that will GET product info and update the website and one that will send orders to my supplier.
  12. I just want an XML API module to import products and send orders to my suppliers........ So I'm asking which is the best...
  13. I'm looking for an XML API module.... Your reply makes no sense lol
×
×
  • Create New...