Search the Community
Showing results for tags 'adminController'.
-
Hello everyone ! As my pseudo say, i'm a junior developer and i have some issues with a module i'm creating. When i install my module, and click on the configure button, i have an error : "the controller is missing or invalid". I don't understand why because it's in the right folder, plus i declared it in the services.yaml. Do you have any idea why ? namespace Controller\Admin; use Doctrine\Common\Cache\CacheProvider; use Maximal\Quantity\Entity\MaxQuantity; use Maximal\Quantity\Repository\MaxQuantityRepository; use Maximal\Quantity\Type\MaxQuantityType; use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; use PrestaShopBundle\Security\Annotation\AdminSecurity; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class MaxQuantityController extends FrameworkBundleAdminController { /** @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") * @return void */ private $cache; public function __construct(CacheProvider $cache) { $this->cache = $cache; parent::construct(); } public function indexAction(MaxQuantityRepository $repository): Response { $produits = $repository->findAll(); return $this->render('@Modules/maximalQuantity/views/templates/admin/index.html.twig', ['produits'=>$produits]); } private function getToolbarButtons() { return [ 'add' => [ 'desc' => $this->trans('Add new maximal quantity', 'Modules.maximalquantity.admin'), 'icon' => 'add_circle_outline', 'href' => $this->generateUrl('module_quantity_create'), ], ]; } /** * Creation d'une nouvelle quantité maximale * * @param Request $request * * @return Response */ public function createAction (Request $request) { $produit = new MaxQuantity(); $maxQuantityFormBuilder = $this->get('maximal.quantity.form.identifiable_object.builder.quantity_form_builder'); $maxQuantityForm = $maxQuantityFormBuilder->getForm([MaxQuantityType::class]); $maxQuantityForm->handleRequest($request); $maxQuantityFormHandler = $this->get('maximal.quantity.form.identifiable_object.data_handler.quantity_form_data_handler'); $result = $maxQuantityFormHandler->handle($maxQuantityForm); if (null !== $result->getIdentifiableObjectId()) { $this->addFlash( 'success', $this->trans('Successful creation.', 'Admin.Notifications.Success') ); return $this->redirectToRoute('module_config'); } return $this-> render('@Modules/maximalquantity/views/templates/admin/create.html.twig', [ 'QuantityForm' => $maxQuantityForm->createView(), ]); } /** * Edit d'une quantité maximale * * @param Request $request * @param int $productId * * @return Response */ public function editAction(Request $request, $productId) { $maxQuantityFormBuilder = $this->get('maximal.quantity.form.identifiable_object.builder.quantity_form_builder'); $maxQuantityForm = $maxQuantityFormBuilder->getFormFor((int)$productId); $maxQuantityForm->handleRequest($request); $maxQuantityFormHandler = $this->get('maximal.quantity.identifiable_object.handler.quantity_form_handler'); $result = $maxQuantityFormHandler->handleFor((int) $productId, $maxQuantityForm); if ($result->isSubmitted() && $result->isValid()) { $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); return $this->redirectToRoute('module_config'); } return $this->render('@Modules/maximalquantity/views/templates/admin/create.html.twig', [ 'QuantityForm' => $maxQuantityForm->createView(), ]); } } Thanks for any help !
- 1 reply
-
- admincontroller
- controller
-
(and 1 more)
Tagged with:
-
Salve, ricevo una serie di errori relativi all'AdminController che mi manda in errore 500 alcune sezioni del backoffice legate ai carrelli abbandonati. Il problema è saltato fuori grazie ad un modulo di terzi che gestisce i carrelli abbandonati che non riusciva a funzionare. A detta dello sviluppatore, il problema è legato al core di PS e nello specifico all'AdminController appunto. In modalità debug, nella pagina dei carrelli abbandonati di PS mi trovo questo: Allego il link alla pagina in html per facilitare la consultazione essendoci diverse voci: https://www.dropbox.com/s/c5wuw2iurnpdjsc/index.php.html?dl=0
- 8 replies
-
- abandoned cart
- carrelli abbandonati
-
(and 2 more)
Tagged with:
-
Dear Prestashop people, We are running multiple stores for a couple of years now, and I have always been wishing if I could just see how much each order costs us, So basically I went ahead and changed the codes a little in the way I saw ideal, but I ended up with a total showing only how much the last product in an order costs, instead of showing the actual cost of the entire order. As you can see in the screenshot above, I was able to add the cost of each product in a new column on the order details page, However, it still only show what that product costs not how much the quantity bought costs (Client bought 2pcs for 15.8EUR while I only see that It costs me 5.89EURO -it should be multiplied by two-). And in the total area as I said it only shows the cost of the last product in the order, which is the one that costs 5.98 EUR, instead it should be the total of prodcut.wholesale_price x product.quantity which will be around 150EUR and certainly not 5.89 EUR. the store is running on PS 1.7.4.2 Any help is highly needed & appreciated.
-
- orders
- backoffice
-
(and 3 more)
Tagged with:
-
Symfony Controller toolbarButtons add selector (id,class)
ZiedDams posted a topic in Core developers
i have created a symfony controller and i added a button in the toolbar , my problem is i want to add attribute like id or class to this button any help ? this is the button -
Bonjour, j'ai eu besoin de surchargé un ModuleAdminController contenant une liste et les filtres ne fonctionnaient pas correctement. Une fois une recherche faite, plus moyen de réinitialiser la recherche et le champ de recherche ne contenait pas la valeur du filtre. Si aucun résultat ne correspondait à la recherche, l'entête de la liste disparaissait et on se retrouvait donc complètement bloqué et obligé de vider les cookies pour retrouver la liste non filtrée. Le problème vient du calcul du préfix utilisé pour stocker la valeur du filtre dans les cookies. Dans le helpler HelperList, le préfix est calculé en fonction du nom du controller (ligne 656) : $prefix = isset($this->controller_name) ? str_replace(array('admin', 'controller'), '', Tools::strtolower($this->controller_name)) : ''; Pour un controller nommé AdminMonModuleController, le préfix généré est : monmodule Dans la classe AdminController, il y a 2 fonctions qui calculent le préfix, une pour les filtres et une pour les tris. Hors, dans ces 2 fonctions, le préfix est calculé en fonction du nom de la classe et non en fonction du nom du controller. protected function getCookieFilterPrefix() { return str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this))); } protected function getCookieOrderByPrefix() { return str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this))); } Comme le nom de ma classe est : AdminMonModuleControllerOverride, le préfix généré est monmoduleoverride et non monmodule J'ai corrigé le problème en faisant un override de la classe AdminController dans lequel je modifie les 2 fonctions concernées. protected function getCookieOrderByPrefix() { $controllerName = $this->controller_name != '' ? $this->controller_name : get_class($this); return str_replace(array('admin', 'controller'), '', Tools::strtolower($controllerName)); } protected function getCookieFilterPrefix() { $controllerName = $this->controller_name != '' ? $this->controller_name : get_class($this); return str_replace(array('admin', 'controller'), '', Tools::strtolower($controllerName)); } Toutes les listes des controllers étendant la classe AdminController fonctionnent correctement avec cette surcharge.
-
- admincontroller
- renderlist
-
(and 2 more)
Tagged with:
-
Je développe en ce moment un module et j'utilise le controller qui hérite du FrameworkBundleAdminController qui rend une vue avec le moteur de template twig mais la vue de mon template avec twig n'herite pas de celle du tableau de bord admin comme celle de la page de configuration de module, vous auriez une piste à me conseillez ?
-
Hola a tod@s Estoy haciendo un modulo para Prestashop 1.7. La idea es, dentro del back-office, en el menú: Configuración de Pedidos anidar un nuevo menú y mostrar un template .tpl para mostrar en una tabla el resultado de una consulta sql. Tengo gran parte ya desarrollada: class modulejat extends Module { public function __construct(){ } public function install() { include(dirname(__FILE__) . '/sql/install.php'); return parent::install() && $this->installModuleTab(); } private function installModuleTab() { $tab = new Tab(); $tab->module = $this->name; $tab->active = 1; $tab->class_name = 'AdminModulejat'; $tab->id_parent = (int)Tab::getIdFromClassName('AdminParentOrders'); $tab->position = Tab::getNewLastPosition($tab->id_parent); foreach (Language::getLanguages(false) as $lang) { $tab->name[(int)$lang['id_lang']] = 'MenuJat'; } return $tab->add(); } // code } Lo que no logro, es mostrar en ese enlace 'MenuJat' el template y o la consulta sql. No he encontrado mucha información. Alguien tiene alguna idea o un ejemplo que me puede ayudar? Muchísimas gracias! PS: 1.7.6.7
- 1 reply
-
- admincontroller
- tpl
-
(and 6 more)
Tagged with:
-
Bonjour à tous, nous avons une problématique à trouver un fichier concernant la modification de la largeur de l'onglet produit (colonne droite) du back office d'un prestasghop 1.7.5. Je pense que le fichier se trouver dans un controller mais je ne sais pas ou chercher spécialement. Merci de l'aide de la communauté. Cordialement.
-
- prestashop
- backoffice
-
(and 5 more)
Tagged with:
-
Hi all After a deep search on forum, I have not found something similar. So, I proceed to explain. I'm developing a little module in 1.6.0.11 and I have a little problem, I think. Mymodule overrides AdminOrdersController.php, it's located in "override/controllers/admin" and it works. In setMedia function added a .js file wich it's located in "modules/mymodule/js/" used to select some element via JQuery. Until here, no problem. public function setMedia() { parent::setMedia(); $this->addJs(_PS_MODULE_DIR_.'mymodule/js/mymodule.js'); $this->addCss(_PS_MODULE_DIR_.'mymodule/css/style.css'); } Now, I want to be able to retrieve ps configuration table values in my mymodule.js, to open a window with base url for example. I know that variable should be passed to tpl template (from my adminordercontroller.php), something like public function renderForm() { $this->context->smarty->assign(array( 'myvariable' => (int)Configuration::get('mymodule_myvariable'), )); $this->content .= $this->createTemplate('form.tpl')->fetch(); } then, I have to define the variable to javascript in tpl file, how and where? "/admin/themes/default/template/controllers/orders/form.tpl"? Thanks in advantage
-
Is it possible to create a helperForm on the product editing page under modules tab? Where our module is present. The only access a module has to that page is through a hook. The controller being used there is AdminProducts controller.
-
- prestashop 1.7
- admincontroller
-
(and 1 more)
Tagged with:
-
Hi everyone, is there a way to turn off debug-mode programmatically? Just temporary. The debug mode helps a lot and I like to use it in my development, but in a most recent case it drives me realy crazy. I just want to (and I have to) handle an easy try catch scenario, wich cannot work due to exceptionHandler of Prestashop (at least in debug mode). Each throw gets caught by the exceptionHandler but not by MY catch block. I think the debug mode cause this behavior. I need to work with Transaction/Commit/Rollback and therefor I need my own exception handling in this case. I don't wand to disable the debug mode by hand. May be there is a way to set the exceptionHandler to NULL, just for the special run, or may be there is another alternative. Any suggestions? Some further information about my situation: I am devolping a module for Prestashop 1.7 and currently stucking in an AdminController Class.
-
- debug-mode
- programmatically
- (and 7 more)
-
Hi everyone! I'm creating my first prestashop e-shop, and now, among other things like theme customization, I've learned in practice the basics of module development, including settings page, front- and backoffice hooks and so on. But I still cant understand how to create an Admin***Controller for my module. Now I know how to create admin menu item (tab) and make my controller just to exist (in other words - my controller page can be opened without errors), but now I'm just using redirect in my Admin***Controller.init() to my module settings page, because that's the only (ugly) way I found to call my module backoffice page from admin menu. So, the question is: is there some step-by-step guide, where the admin controller creation basics described like the module creation described in official PS docs? the only thing I found in PS docs about controller is short description about some fields of frontend controller (but it just helped me to understand the concept of usinc controller - create tpl, fill some magic data, call display*** methods - and happyness will come), but nothing else... Thanks in advance for your help
-
Hello, I'm developing a custom module and i want to add a clickable link in a column inside a table in a Admin Module Controller. in the example image, i want to add a link that takes me to the client's profile.
-
- admincontroller
- link
-
(and 1 more)
Tagged with:
-
I know how to add the export option to any admin list. It is done with `$this->allow_export=true` in the corresponding AdminController. But how can you add it to the group view, which is in fact a list of customers for that group?. If I add `$this->allow_export=true` to AdminGroupsController then the list of groups is exportable, but not the list of customers that you get when you click in a group show icon. I looked at the source code and I saw that the list is generated with the `HelperList` class, but I didn't see anything helpful there. Thanks.
-
Buonasera a tutti, ho acquistato il modulo Product Area Packs Calculator da addons.prestashop http://addons.prestashop.com/it/18522-product-area-packs-calculator.html l'ho installato, ma per ogni cosa io provi a settare mi restituisce sempre lo stesso errore: "[PrestaShop] Fatal error in module AdminController: Class name must be a valid object or a string" ho la versione prestashop 1.5.4 Qualcuno può aiutarmi? É urgentissimo, grazie mille!
- 5 replies
-
- modulo
- must be a valid object
- (and 6 more)
-
Hello, PS version 1.6.1.1 I need some help ; cannot figure out how to solve my problem. Here it is : I have a new customized module called myanimal. Problem description Module works fine when installing (creation of tables, insertion of resources in architecture...). This module has 2 front controllers that work fine too (creating animals). Now I want to add a tab in backoffice so that administrator can see animals created. I plan to use helpers, I just want a basic table list as we have plenty in PS. So I created an AdminAnimalController extending ModuleAdminController and set it in modules/myanimal/controllers/admin/AdminAnimalController.php When installing the module I create the new tab in backoffice right menu, under 'customers'. But when clicking on it I get 'Class 'AdminAnimalController' not found in BASE_DIR/classes/controller/Controller.php on line 134 I checked Controller.php ; it is logically about getController method and in my case the controller is not found. What I tried : Delete index_cache in BASE_DIR/cache Scrutinize database see if I had to save my controller in a routing table... I thought it could very well be a naming convention problem but when I look at other AdminControllers like AdminCarriersController it seems I am going fine...?? But ??? Quid ? Can someone help please ? See below my AdminController file. Alexandre <?php class AdminAnimalControllerCore extends ModuleAdminController { public function __construct() { // INCLUDE NEW OBJECT MODEL FROM MODULE DIRECTORY include_once(__DIR__.'../../../classes/MyAnimal.php'); $this->table = 'my_animal'; $this->className = 'MyAnimal'; $this->lang = false; $this->deleted = false; $this->colorOnBackground = false; $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); $this->context = Context::getContext(); // définition de l'upload, chemin par défaut _PS_IMG_DIR_ $this->fieldImageSettings = array('name' => 'image', 'dir' => 'example'); // This adds a multiple deletion button $this->bulk_actions = array( 'delete' => array( 'text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?') ) ); parent::__construct(); } // This method generates the list of results public function renderList() { // Adds a Delete button for each result $this->addRowAction('delete'); $this->bulk_actions = array( 'delete' => array( 'text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?') ) ); // Building the list of records stored within the "test" table $this->fields_list = array( 'id' => array( 'title' => $this->l('ID'), 'align' => 'center', 'width' => 20 ), 'id_customer' => array( 'title' => $this->l('CLIENT'), 'align' => 'left', 'width' => 25 ), 'name' => array( 'title' => $this->l('Name'), 'align' => 'left', 'width' => 'auto' ), 'date_birth' => array( 'title' => $this->l('Date de naissance'), 'align' => 'left', 'width' => 20 ), 'type' => array( 'title' => $this->l('Espèce'), 'align' => 'left', 'width' => 10 ), 'age_slice' => array( 'title' => $this->l('Tranche d\'âge'), 'align' => 'left', 'width' => 20 ), 'description' => array( 'title' => $this->l('Description'), 'align' => 'left', 'width' => 150 ), 'img_url' => array( 'title' => $this->l('Image'), 'align' => 'left', 'width' => 'auto' ) ); $lists = parent::renderList(); parent::initToolbar(); return $lists; } // This method generates the Add/Edit form public function renderForm() { return parent::renderForm(); } }
- 4 replies
-
- new module
- adminController
-
(and 2 more)
Tagged with:
-
Witam, Potrzebuję zmienić tekst wyświetlany w pasku nagłówka edycji produktu- jak na załączonym obrazku: Domyślnie nazwa pobierana jest z nazwy produktów - chciałbym pobierać ją z meta_title. Który plik muszę edytować, aby osiągnąć zamierzony efekt? Po godzinach grzebania w kodzie doszedłem do tego, że za wyświetlanie ww tytułów prawdopodobnie odpowiada metoda initToolbarTitle(): classes/controller/AdminController.php public function initToolbarTitle() { $this->toolbar_title = is_array($this->breadcrumbs) ? array_unique($this->breadcrumbs) : array($this->breadcrumbs); switch ($this->display) { case 'edit': $this->toolbar_title[] = $this->l('Edit', null, null, false); break; case 'add': $this->toolbar_title[] = $this->l('Add new', null, null, false); break; case 'view': $this->toolbar_title[] = $this->l('View', null, null, false); break; } if ($filter = $this->addFiltersToBreadcrumbs()) $this->toolbar_title[] = $filter; } Nie mam jednak pojęcia w jaki sposób pobierana jest nazwa produktu do nagłówka i gdzie ją zmienić. Podejrzewam, że ma to coś wspólnego ze zmienną $filter lub może dzieje się to na poziomie szablonów Smarty? Jeżeli ktoś się w tym orientuje, proszę o pomoc. Wersja PrestaShop: 1.6.0.11
-
- edycja produktu
- AdminController
- (and 5 more)
-
Hola, estoy creando un nuevo controlador para regiones y comunas para chile, tengo el problema al crear un nuevo controller, el nombre del controlador es AdminRegionControllerCore, al entrar por el link index.php?controller=AdminRegion no me muestra nada y en el registro de errores queda esto [13-Jan-2016 19:40:59 America/Santiago] PHP Fatal error: Uncaught Error: Class 'AdminRegionController' not found in /home/codemake/public_html_other/testing.codemaker.cl/www.thebeat.cl/classes/controller/Controller.php:134 Stack trace: #0 /home/codemake/public_html_other/testing.codemaker.cl/www.thebeat.cl/classes/Dispatcher.php(359): ControllerCore::getController('AdminRegionCont...') #1 /home/codemake/public_html_other/testing.codemaker.cl/www.thebeat.cl/admin927cdc1kg/index.php(58): DispatcherCore->dispatch() #2 {main} thrown in /home/codemake/public_html_other/testing.codemaker.cl/www.thebeat.cl/classes/controller/Controller.php on line 134 pero al abrir otro link como este index.php?controller=AdminRegions, me muestra una pantalla donde dice que no se encontro el modulo. Este es mi AdminRegionController.php <?php /* * 2007-2015 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2015 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ /** * @property Region $object */ class AdminRegionControllerCore extends AdminController { public function __construct() { $this->bootstrap = true; $this->table = 'regiones'; $this->className = 'Region'; $this->lang = false; $this->requiredDatabase = true; $this->addRowAction('edit'); $this->addRowAction('delete'); $this->context = Context::getContext(); if (!Tools::getValue('realedit')) { $this->deleted = false; } $this->bulk_actions = array( 'delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), 'affectzone' => array('text' => $this->l('Assign a new zone')) ); $this->_select = 'z.`name` AS zone, cl.`name` AS country'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = a.`id_zone`) LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (cl.`id_country` = a.`id_country` AND cl.id_lang = '.(int)$this->context->language->id.')'; $this->_use_found_rows = false; $countries_array = $zones_array = array(); $this->zones = Zone::getZones(); $this->countries = Country::getCountries($this->context->language->id, false, true, false); foreach ($this->zones as $zone) { $zones_array[$zone['id_zone']] = $zone['name']; } foreach ($this->countries as $country) { $countries_array[$country['id_country']] = $country['name']; } $this->fields_list = array( 'id_state' => array( 'title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs' ), 'name' => array( 'title' => $this->l('Name'), 'filter_key' => 'a!name' ), 'iso_code' => array( 'title' => $this->l('ISO code'), 'align' => 'center', 'class' => 'fixed-width-xs' ), 'zone' => array( 'title' => $this->l('Zone'), 'type' => 'select', 'list' => $zones_array, 'filter_key' => 'z!id_zone', 'filter_type' => 'int', 'order_key' => 'zone' ), 'country' => array( 'title' => $this->l('Country'), 'type' => 'select', 'list' => $countries_array, 'filter_key' => 'cl!id_country', 'filter_type' => 'int', 'order_key' => 'country' ), 'active' => array( 'title' => $this->l('Enabled'), 'active' => 'status', 'filter_key' => 'a!active', 'align' => 'center', 'type' => 'bool', 'orderby' => false, 'class' => 'fixed-width-sm' ) ); parent::__construct(); } public function initPageHeaderToolbar() { if (empty($this->display)) { $this->page_header_toolbar_btn['new_state'] = array( 'href' => self::$currentIndex.'&addregion&token='.$this->token, 'desc' => $this->l('Add new region', null, null, false), 'icon' => 'process-icon-new' ); } parent::initPageHeaderToolbar(); } public function renderForm() { $this->fields_form = array( 'legend' => array( 'title' => $this->l('States'), 'icon' => 'icon-globe' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Provide the State name to be display in addresses and on invoices.') ), array( 'type' => 'text', 'label' => $this->l('ISO code'), 'name' => 'iso_code', 'maxlength' => 7, 'required' => true, 'class' => 'uppercase', 'hint' => $this->l('1 to 4 letter ISO code.').' '.$this->l('You can prefix it with the country ISO code if needed.') ), array( 'type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => true, 'default_value' => (int)$this->context->country->id, 'options' => array( 'query' => Country::getCountries($this->context->language->id, false, true), 'id' => 'id_country', 'name' => 'name', ), 'hint' => $this->l('Country where the state is located.').' '.$this->l('Only the countries with the option "contains states" enabled are displayed.') ), array( 'type' => 'select', 'label' => $this->l('Zone'), 'name' => 'id_zone', 'required' => true, 'options' => array( 'query' => Zone::getZones(), 'id' => 'id_zone', 'name' => 'name' ), 'hint' => array( $this->l('Geographical region where this state is located.'), $this->l('Used for shipping') ) ), array( 'type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" />' ), array( 'id' => 'active_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" />' ) ) ) ), 'submit' => array( 'title' => $this->l('Save'), ) ); return parent::renderForm(); } public function postProcess() { if (Tools::isSubmit($this->table.'Orderby') || Tools::isSubmit($this->table.'Orderway')) { $this->filter = true; } // Idiot-proof controls if (!Tools::getValue('id_'.$this->table)) { if (Validate::isStateIsoCode(Tools::getValue('iso_code')) && State::getIdByIso(Tools::getValue('iso_code'), Tools::getValue('id_country'))) { $this->errors[] = Tools::displayError('This ISO code already exists. You cannot create two states with the same ISO code.'); } } elseif (Validate::isStateIsoCode(Tools::getValue('iso_code'))) { $id_state = State::getIdByIso(Tools::getValue('iso_code'), Tools::getValue('id_country')); if ($id_state && $id_state != Tools::getValue('id_'.$this->table)) { $this->errors[] = Tools::displayError('This ISO code already exists. You cannot create two states with the same ISO code.'); } } /* Delete state */ if (Tools::isSubmit('delete'.$this->table)) { if ($this->tabAccess['delete'] === '1') { if (Validate::isLoadedObject($object = $this->loadObject())) { /** @var State $object */ if (!$object->isUsed()) { if ($object->delete()) { Tools::redirectAdmin(self::$currentIndex.'&conf=1&token='.(Tools::getValue('token') ? Tools::getValue('token') : $this->token)); } $this->errors[] = Tools::displayError('An error occurred during deletion.'); } else { $this->errors[] = Tools::displayError('This state was used in at least one address. It cannot be removed.'); } } else { $this->errors[] = Tools::displayError('An error occurred while deleting the object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)'); } } else { $this->errors[] = Tools::displayError('You do not have permission to delete this.'); } } if (!count($this->errors)) { parent::postProcess(); } } protected function displayAjaxStates() { $states = Db::getInstance()->executeS(' SELECT s.id_state, s.name FROM '._DB_PREFIX_.'state s LEFT JOIN '._DB_PREFIX_.'country c ON (s.`id_country` = c.`id_country`) WHERE s.id_country = '.(int)(Tools::getValue('id_country')).' AND s.active = 1 AND c.`contains_states` = 1 ORDER BY s.`name` ASC'); if (is_array($states) and !empty($states)) { $list = ''; if ((bool)Tools::getValue('no_empty') != true) { $empty_value = (Tools::isSubmit('empty_value')) ? Tools::getValue('empty_value') : '-'; $list = '<option value="0">'.Tools::htmlentitiesUTF8($empty_value).'</option>'."\n"; } foreach ($states as $state) { $list .= '<option value="'.(int)($state['id_state']).'"'.((isset($_GET['id_state']) and $_GET['id_state'] == $state['id_state']) ? ' selected="selected"' : '').'>'.$state['name'].'</option>'."\n"; } } else { $list = 'false'; } die($list); } } No encuentro el problema, el controlador no esta completamente terminado, en este momento solo muestra datos de provincias. Saludos
- 1 reply
-
- controller
- admincontroller
-
(and 2 more)
Tagged with:
-
Hi, I'm creating a new driver for regions and municipalities in Chile, I have a problem creating a new controller, the controller name is AdminRegionControllerCore, entering the link index.php?Controller=AdminRegion not show me anything and checking this error is [13-Jan-2016 19:40:59 America/Santiago] PHP Fatal error: Uncaught Error: Class 'AdminRegionController' not found in /home/codemake/public_html_other/testing.codemaker.cl/www.thebeat.cl/classes/controller/Controller.php:134 Stack trace: #0 /home/codemake/public_html_other/testing.codemaker.cl/www.thebeat.cl/classes/Dispatcher.php(359): ControllerCore::getController('AdminRegionCont...') #1 /home/codemake/public_html_other/testing.codemaker.cl/www.thebeat.cl/admin927cdc1kg/index.php(58): DispatcherCore->dispatch() #2 {main} thrown in /home/codemake/public_html_other/testing.codemaker.cl/www.thebeat.cl/classes/controller/Controller.php on line 134 but to open another link like this index.php?controller=AdminRegions shows me a screen that says the module is not found. This is my AdminRegionController.php <?php /* * 2007-2015 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2015 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ /** * @property Region $object */ class AdminRegionControllerCore extends AdminController { public function __construct() { $this->bootstrap = true; $this->table = 'regiones'; $this->className = 'Region'; $this->lang = false; $this->requiredDatabase = true; $this->addRowAction('edit'); $this->addRowAction('delete'); $this->context = Context::getContext(); if (!Tools::getValue('realedit')) { $this->deleted = false; } $this->bulk_actions = array( 'delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), 'affectzone' => array('text' => $this->l('Assign a new zone')) ); $this->_select = 'z.`name` AS zone, cl.`name` AS country'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = a.`id_zone`) LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (cl.`id_country` = a.`id_country` AND cl.id_lang = '.(int)$this->context->language->id.')'; $this->_use_found_rows = false; $countries_array = $zones_array = array(); $this->zones = Zone::getZones(); $this->countries = Country::getCountries($this->context->language->id, false, true, false); foreach ($this->zones as $zone) { $zones_array[$zone['id_zone']] = $zone['name']; } foreach ($this->countries as $country) { $countries_array[$country['id_country']] = $country['name']; } $this->fields_list = array( 'id_state' => array( 'title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs' ), 'name' => array( 'title' => $this->l('Name'), 'filter_key' => 'a!name' ), 'iso_code' => array( 'title' => $this->l('ISO code'), 'align' => 'center', 'class' => 'fixed-width-xs' ), 'zone' => array( 'title' => $this->l('Zone'), 'type' => 'select', 'list' => $zones_array, 'filter_key' => 'z!id_zone', 'filter_type' => 'int', 'order_key' => 'zone' ), 'country' => array( 'title' => $this->l('Country'), 'type' => 'select', 'list' => $countries_array, 'filter_key' => 'cl!id_country', 'filter_type' => 'int', 'order_key' => 'country' ), 'active' => array( 'title' => $this->l('Enabled'), 'active' => 'status', 'filter_key' => 'a!active', 'align' => 'center', 'type' => 'bool', 'orderby' => false, 'class' => 'fixed-width-sm' ) ); parent::__construct(); } public function initPageHeaderToolbar() { if (empty($this->display)) { $this->page_header_toolbar_btn['new_state'] = array( 'href' => self::$currentIndex.'&addregion&token='.$this->token, 'desc' => $this->l('Add new region', null, null, false), 'icon' => 'process-icon-new' ); } parent::initPageHeaderToolbar(); } public function renderForm() { $this->fields_form = array( 'legend' => array( 'title' => $this->l('States'), 'icon' => 'icon-globe' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Provide the State name to be display in addresses and on invoices.') ), array( 'type' => 'text', 'label' => $this->l('ISO code'), 'name' => 'iso_code', 'maxlength' => 7, 'required' => true, 'class' => 'uppercase', 'hint' => $this->l('1 to 4 letter ISO code.').' '.$this->l('You can prefix it with the country ISO code if needed.') ), array( 'type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => true, 'default_value' => (int)$this->context->country->id, 'options' => array( 'query' => Country::getCountries($this->context->language->id, false, true), 'id' => 'id_country', 'name' => 'name', ), 'hint' => $this->l('Country where the state is located.').' '.$this->l('Only the countries with the option "contains states" enabled are displayed.') ), array( 'type' => 'select', 'label' => $this->l('Zone'), 'name' => 'id_zone', 'required' => true, 'options' => array( 'query' => Zone::getZones(), 'id' => 'id_zone', 'name' => 'name' ), 'hint' => array( $this->l('Geographical region where this state is located.'), $this->l('Used for shipping') ) ), array( 'type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" />' ), array( 'id' => 'active_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" />' ) ) ) ), 'submit' => array( 'title' => $this->l('Save'), ) ); return parent::renderForm(); } public function postProcess() { if (Tools::isSubmit($this->table.'Orderby') || Tools::isSubmit($this->table.'Orderway')) { $this->filter = true; } // Idiot-proof controls if (!Tools::getValue('id_'.$this->table)) { if (Validate::isStateIsoCode(Tools::getValue('iso_code')) && State::getIdByIso(Tools::getValue('iso_code'), Tools::getValue('id_country'))) { $this->errors[] = Tools::displayError('This ISO code already exists. You cannot create two states with the same ISO code.'); } } elseif (Validate::isStateIsoCode(Tools::getValue('iso_code'))) { $id_state = State::getIdByIso(Tools::getValue('iso_code'), Tools::getValue('id_country')); if ($id_state && $id_state != Tools::getValue('id_'.$this->table)) { $this->errors[] = Tools::displayError('This ISO code already exists. You cannot create two states with the same ISO code.'); } } /* Delete state */ if (Tools::isSubmit('delete'.$this->table)) { if ($this->tabAccess['delete'] === '1') { if (Validate::isLoadedObject($object = $this->loadObject())) { /** @var State $object */ if (!$object->isUsed()) { if ($object->delete()) { Tools::redirectAdmin(self::$currentIndex.'&conf=1&token='.(Tools::getValue('token') ? Tools::getValue('token') : $this->token)); } $this->errors[] = Tools::displayError('An error occurred during deletion.'); } else { $this->errors[] = Tools::displayError('This state was used in at least one address. It cannot be removed.'); } } else { $this->errors[] = Tools::displayError('An error occurred while deleting the object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)'); } } else { $this->errors[] = Tools::displayError('You do not have permission to delete this.'); } } if (!count($this->errors)) { parent::postProcess(); } } protected function displayAjaxStates() { $states = Db::getInstance()->executeS(' SELECT s.id_state, s.name FROM '._DB_PREFIX_.'state s LEFT JOIN '._DB_PREFIX_.'country c ON (s.`id_country` = c.`id_country`) WHERE s.id_country = '.(int)(Tools::getValue('id_country')).' AND s.active = 1 AND c.`contains_states` = 1 ORDER BY s.`name` ASC'); if (is_array($states) and !empty($states)) { $list = ''; if ((bool)Tools::getValue('no_empty') != true) { $empty_value = (Tools::isSubmit('empty_value')) ? Tools::getValue('empty_value') : '-'; $list = '<option value="0">'.Tools::htmlentitiesUTF8($empty_value).'</option>'."\n"; } foreach ($states as $state) { $list .= '<option value="'.(int)($state['id_state']).'"'.((isset($_GET['id_state']) and $_GET['id_state'] == $state['id_state']) ? ' selected="selected"' : '').'>'.$state['name'].'</option>'."\n"; } } else { $list = 'false'; } die($list); } }
-
- admincontroller
- new controller
-
(and 2 more)
Tagged with:
-
I want be able to update data in the corresponding MySQL table.. For example when I disable/enable a product, I want date_upd (update date) to be updated with the date/time of that specific moment.. I have found something but I am not sure how to continue from that point ../classes/controller/AdminContoller.php line 1232: public function processStatus() ../classes/Product.php line 841: public function toggleStatus() Thanx in advance
-
- toggleStatus
- 1.6
-
(and 3 more)
Tagged with:
-
We are extending Prestashop 1.6 with a "Parent" AdminTab and multiple "child" AdminTabs referencing separate classes for adding specialist functionality. The tab navigation works successfully, but we have become a little unstuck in defining the images that appear in the menu on the left and the page toolbar title at the top of each page (in green banner). Where should the physical assets sit? Which property of the Tab or AdminController should we be checking/linking? Thanks Rob
- 7 replies
-
- admintab
- admincontroller
-
(and 2 more)
Tagged with:
-
this is my code: class MyModuleController extends AdminController { public function __construct() { $this->bootstrap = true; parent::__construct(); } public function initContent() { parent::initContent(); }}mymodule.tpl: <h1>Hello world</h1> Now, I want to click on the tab, which will display the file contents are stored in mymodule.tpl Somebody can help me? (mymodule directories structure in attach file)
-
Hello, I have a question. I am creating a new module. I understand the MVC and have no issues getting the admin controller and admin class files working. Overall, I like how Prestashop makes it very easy to display data via a custom tab and admin controller file. However, what I cannot seem to figure out is how do you display a custom TPL file connected to a tab link. Or lets say you have a controller file that lists a bunch of users using Prestashop's array controller - class format.. How do you display a custom TPL file when you click on a customer account? In other words, we all know that when you create a module you have a php file that handles the installation and directs to a setup page (if needed) that is linked to a TPL file which you can customize however you want. I would like to do the same thing with the admin pages. I would like to have a tab in the admin menu (already got it created) that instead of being forced to use the array commands to display table data I would like when a user clicks on it to load a tpl file instead. I have tried many variations... but cannot get the tab link to show a TPL file... any ideas? Something tells me this should be very easy and I am probably making it more complicated then it really is.
-
- tpl
- admincontroller
-
(and 5 more)
Tagged with:
-
Hi all. I need some help or inspiration. I´m making a module for my boss. We want to modify the prices depeding on the destination of the order. For the module I´m using some tabs, and into the tab class I´m using the next code to declare the form to pass the data directly to database: public function renderForm(){ if (Tools::isSubmit('add'.$this->table)){ $this->fields_form =... ... } } In the constructor of this class I declare primary key of my mysql table this way: $this->identifier = "ID_RATE"; //the primary key The problem now, that I have not seen in Canvas example module that we can find in this forum and in internet, is that a hidden input appears. This is the html code of the input: <input type="hidden" name="ID_RATE" id="ID_RATE" value="255"> I can confirm that if I modify in the constructor the identifier param, in the input it gets modified too. The value of the input (255) is the id of the tab into ps_tab table. So, if I try to get the value of other input with a name of ID_RATE (like I do) for saving a new rate or modifing an existing one, the system always take this input as the source of this data, making all the process to fail. Today it started to happend this to me, yesterday it was working fine, I don´t know what I did to break this. Why is this happening to me and not to canvas module, for example ? I´m going to upload the full alpha version in developing right now for the people who wants to take a look at this. If you want to compare, I´m going to upload the example canvas module also. Thanks you very much in advance. Please fell free to ask everythin you want about this. modules.zip
- 3 replies
-
- admincontroller
- moduleadmincontroller
-
(and 5 more)
Tagged with:
-
Buenas gente estoy aprendiendo a armar un admin controller a fuerzas de prueba y error, pero se me presento algo que me esta llevando dias solucionarlo, quizas alguno de todos uds. sepa como solucionarlo. Estoy tratando de meter un codigo script para que en el formulario que creo me agrege selects combinados. La cuestion es que nose como declararlo.Aqui les dejo el codigo del admincontroller y el javascript que quiero agregar. <?php include_once('../classes/materiales.php'); include_once('../js/selects_combinados.js'); class AdminMaterialesControllerCore extends AdminController { public function __construct() // Método que inicializa el tab { $this->table = 'materiales'; $this->identifier = 'id_material'; $this->className = 'Materiales'; $this->fields_list = array( 'id_material' => array('title' => $this->l('ID'),'align' => 'center','width' => 25, 'tag' => 'label' , 'type' => 'text'), 'comprado' => array('title' => $this->l('Fecha de compra'),'width' => 100 , 'type' => 'date'), 'proveedor' => array('title' => $this->l('Proveedor'),'width' => 150 , 'tag' => 'select' , 'type' => 'text', 'value' => '111'), 'category' => array('title' => $this->l('Categoria'),'width' => 100 , 'tag' => 'select' , 'type' => 'text'), 'type_product' => array('title' => $this->l('Tipo de producto'),'width' => 100 , 'tag' => 'select' , 'type' => 'text'), 'color' => array('title' => $this->l('Color'),'width' => 50 , 'tag' => 'input' , 'type' => 'color'), 'um' => array('title' => $this->l('Unidad de medicion'),'align' => 'center', 'width' => 50 , 'tag' => 'input' , 'type' => 'text'), 'cantidad' => array('title' => $this->l('Cantidad'),'align' => 'center', 'width' => 50 , 'tag' => 'input' , 'type' => 'text'), 'peso' => array('title' => $this->l('Peso grs'),'align' => 'center','width' => 35 , 'tag' => 'input' , 'type' => 'text'), 'largo' => array('title' => $this->l('Largo cm'),'align' => 'center','width' => 35 , 'tag' => 'input' , 'type' => 'text'), 'ancho' => array('title' => $this->l('Ancho cm'),'align' => 'center','width' => 35 , 'tag' => 'input' , 'type' => 'text'), 'compra' => array('title' => $this->l('Valor de compra'),'align' => 'center', 'width' => 35 , 'type' => 'price'), 'recargo' => array('title' => $this->l('% de recargo'),'align' => 'center', 'width' => 35 , 'type' => 'price'), 'venta' => array('title' => $this->l('Valor de venta'),'align' => 'center', 'width' => 35 , 'type' => 'price'), 'costo' => array('title' => $this->l('Valor de venta UMM'),'align' => 'center', 'width' => 35 , 'type' => 'price') ); parent::__construct(); } public function renderForm() // Esta función se usa apra crear el formulario { $this->initToolbar(); $obj = $this->loadObject(false); $id_shop = Context::getContext()->shop->id; //Carga el objeto seleccionado if (!$obj = new Materiales((int)Tools::getValue($this->identifier))) return; // Arma las opciones de los SELECT //Carga lista de proveedores $sql_proveedor = 'SELECT name FROM '._DB_PREFIX_.'supplier'; $lista_proveedores= Db::getInstance()->executeS($sql_proveedor); //Carga lista de categorias $sql_categorias = 'SELECT id_attribute_group, name FROM '._DB_PREFIX_.'attribute_group_lang WHERE (id_lang = 2) AND ((id_attribute_group = 1) OR (id_attribute_group = 3) OR (id_attribute_group = 6))'; $lista_categorias= Db::getInstance()->executeS($sql_categorias); //Carga lista de produuctos // $sql_producto = 'SELECT pal.name FROM '._DB_PREFIX_.'attribute_lang pal LEFT JOIN '._DB_PREFIX_.'attribute pa ON pa.id_attribute = pal.id_attribute WHERE (pal.id_lang = 2) AND (pa.id_attribute_group = 3)'; // $lista_productos= Db::getInstance()->executeS($sql_producto); $selectDestino=$_GET["select"]; $opcionSeleccionada=$_GET["opcion"]; if(validaSelect($selectDestino) && validaOpcion($opcionSeleccionada)) { $sql_producto = 'SELECT pal.name FROM '._DB_PREFIX_.'attribute_lang pal LEFT JOIN '._DB_PREFIX_.'attribute pa ON pa.id_attribute = pal.id_attribute WHERE (pal.id_lang = 2) AND (pa.id_attribute_group = '.$opcionSeleccionada.')'; $lista_productos= Db::getInstance()->executeS($sql_producto); } //--- //Devuelve los valores x fila o sea un producto. $sql_producto_seleccionado = 'SELECT * FROM '._DB_PREFIX_.$this->table.' WHERE id_material = '.$obj->id.''; $producto = Db::getInstance()->getRow($sql_producto_seleccionado); //---- $um = array( array('id'=>'grs','name'=>'grs'), array('id'=>'kg','name'=>'kg'), array('id'=>'unidad','name'=>'unidad') ); $this->fields_form = array( 'legend' => array( 'title' => $this->l('Listado de precio de materiales'), 'image' => '../img/admin/AdminPdf.gif' ), 'input' => array( array('type' => 'text', 'label' => $this->l('ID'), 'name' => 'id_material', 'size'=>25), array('type' => 'date', 'label' => $this->l('Fecha de compra'), 'name' => 'comprado', 'size' => 30), array('type' => 'select', 'label' => $this->l('Proveedor'), 'name' => 'proveedor', 'options' => array('query' => $lista_proveedores,'id' => 'name','name' => 'name')), array('type' => 'select', 'label' => $this->l('Categoria'), 'name' => 'category', 'onchange'=>'cargaContenido(this.id)', 'options' => array('query' => $lista_categorias,'id' => 'id_attribute_group','name' => 'name')), array('type' => 'select', 'label' => $this->l('Producto'), 'name' => 'type_product', 'options' => array('query' => $lista_productos,'id' => 'name','name' => 'name')), array('type' => 'color', 'label' => $this->l('Color'), 'name' => 'color', 'size' => 25), array('type' => 'select', 'label' => $this->l('Unidad de medicion'), 'name' => 'um', 'options' => array('query'=>$um,'id' => 'name','name' => 'name')), array('type' => 'text', 'label' => $this->l('Largo'), 'name' => 'largo', 'align' => 'center','size' => 35), array('type' => 'text', 'label' => $this->l('Ancho'), 'name' => 'ancho', 'align' => 'center','size' => 35), array('type' => 'text', 'label' => $this->l('Peso'), 'name' => 'peso', 'align' => 'center','size' => 35), array('type' => 'text', 'label' => $this->l('COMPRA'), 'name' => 'precio', 'align' => 'left', 'size' => 35), array('type' => 'text', 'label' => $this->l('COMPRA - UMM'), 'name' => 'umv', 'align' => 'center', 'size' => 50), array('type' => 'text', 'label' => $this->l('VENTA'), 'name' => 'costo', 'align' => 'left', 'size' => 35), array('type' => 'text', 'label' => $this->l('VENTA - UMM'), 'name' => 'umc', 'align' => 'center', 'size' => 50) ), 'submit' => array( 'title' => $this->l('Guardar'), 'class' => 'button' ) ); foreach ($this->fields_list as $field => $value) {$this->fields_value[$field] = $producto[$field];} return parent::renderForm(); } public function renderList() { $this->addRowAction('edit'); $this->addRowAction('delete'); return parent::renderList(); } public function postProcess() // Esta función se ejecuta con el botón submit generalmente se usa para guardar los datos en la base de datos { Tools::getValue('id_material'); Tools::getValue('comprado'); Tools::getValue('proveedor'); Tools::getValue('category'); Tools::getValue('type_product'); Tools::getValue('color'); Tools::getValue('largo'); Tools::getValue('ancho'); Tools::getValue('peso'); parent::postProcess(); } }?> y esto es el codigo javascript function nuevoAjax() { /* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por lo que se puede copiar tal como esta aqui */ var xmlhttp=false; try { // Creacion del objeto AJAX para navegadores no IE xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { // Creacion del objet AJAX para IE xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(E) { if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp=new XMLHttpRequest(); } } return xmlhttp; } // Declaro los selects que componen el documento HTML. Su atributo ID debe figurar aqui. var listadoSelects=new Array(); listadoSelects[0]="category"; listadoSelects[1]="type_product"; function buscarEnArray(array, dato) { // Retorna el indice de la posicion donde se encuentra el elemento en el array o null si no se encuentra var x=0; while(array[x]) { if(array[x]==dato) return x; x++; } return null; } function cargaContenido(idSelectOrigen) { // Obtengo la posicion que ocupa el select que debe ser cargado en el array declarado mas arriba var posicionSelectDestino=buscarEnArray(listadoSelects, idSelectOrigen)+1; // Obtengo el select que el usuario modifico var selectOrigen=document.getElementById(idSelectOrigen); // Obtengo la opcion que el usuario selecciono var opcionSeleccionada=selectOrigen.options[selectOrigen.selectedIndex].value; // Si el usuario eligio la opcion "Elige", no voy al servidor y pongo los selects siguientes en estado "Selecciona opcion..." if(opcionSeleccionada==0) { var x=posicionSelectDestino, selectActual=null; // Busco todos los selects siguientes al que inicio el evento onChange y les cambio el estado y deshabilito while(listadoSelects[x]) { selectActual=document.getElementById(listadoSelects[x]); selectActual.length=0; var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Selecciona Opción..."; selectActual.appendChild(nuevaOpcion); selectActual.disabled=true; x++; } } // Compruebo que el select modificado no sea el ultimo de la cadena else if(idSelectOrigen!=listadoSelects[listadoSelects.length-1]) { // Obtengo el elemento del select que debo cargar var idSelectDestino=listadoSelects[posicionSelectDestino]; var selectDestino=document.getElementById(idSelectDestino); // Creo el nuevo objeto AJAX y envio al servidor el ID del select a cargar y la opcion seleccionada del select origen var ajax=nuevoAjax(); ajax.open("GET", "select_dependientes_proceso.php?select="+idSelectDestino+"&opcion="+opcionSeleccionada, true); ajax.onreadystatechange=function() { if (ajax.readyState==1) { // Mientras carga elimino la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..." selectDestino.length=0; var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Cargando..."; selectDestino.appendChild(nuevaOpcion); selectDestino.disabled=true; } if (ajax.readyState==4) { selectDestino.parentNode.innerHTML=ajax.responseText; } } ajax.send(null); } } Muchas gracias de antemano.