[#3017] including a php file during a plan registration ?

12 years 6 months ago #182420 by activha
Mmmm the script is fully tested and working very well :-)

The thing is that it does not work with Cbsubs integration... seems like we have so many problems with cbsubs integrations...

A little help on this while waiting for PAP solving... next year maybe ?? ;-)

Please Log in to join the conversation.

12 years 5 months ago - 12 years 5 months ago #182948 by krileon

But this just fails with an error in the back end
Fatal error: Call to a member function commitTabsContents() on a non-object in /Applications/MAMP/htdocs/activnew/administrator/components/com_comprofiler/library/cb/cb.tables.php on line 1494

Do you happen to have a stack call for this error? Can only see this happening if "$this->_cbTabs" isn't populated and if it isn't then the entire registration wouldn't work right. Does this only happen when you use the queries in a CBSubs SQL Action? For SQL Actions your queries should be as follows.
INSERT INTO `#__enmasse_sales_person` ( `name`, `user_name`, `address`, `phone`, `email`, `zip_code`, `city`, `country`, `published`, `created_at`,`updated_at` ) VALUES( '[name]', '[username]', '[address]', '[phone]',  '[email]', '[zipcode]', '[city]', '[country]', '1', NOW(), NOW() ); 
INSERT INTO `#__enmasse_merchant_branch` ( `name`, `user_name`, `sales_person_id`, `branches`, `zip_code`, `city`, `country`, `published`, `created_at`, `updated_at` ) VALUES( '[name]', '[username]', LAST_INSERT_ID(), '{"branch1":{"branchname":"branch1","name":"[name]","description":"","google_map_width":"200","google_map_height":"200","address":"[address]","telephone":"[phone]","fax":"[fax]","google_map_lat":"","google_map_long":"","google_map_zoom":""}}', '[zipcode]', '[city]', '[country]', '1', NOW(), NOW() );
INSERT INTO `#__user_usergroup_map` ( `user_id`, `group_id` ) VALUES ( '[user_id]', ( SELECT `merchant_group` FROM `#__enmasse_setting` ) ), ( '[user_id]', ( SELECT `sale_group` FROM `#__enmasse_setting` ) );

Instead of INSERT INTO you may want to use REPLACE though so it'll insert if doesn't exist and will replace if it does exist to help prevent duplicates or errors due to duplicate already existing.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

12 years 5 months ago - 12 years 5 months ago #182996 by activha
We tried a query with the following script (from line 6 to line 52) and it failed also.

Yes we are trying to use only the mysql integration in cbsubs.

We have the error :
Fatal error: Call to a member function commitTabsContents() on a non-object in /Applications/MAMP/htdocs/activnew/administrator/components/com_comprofiler/library/cb/cb.tables.php on line 1494

But no other errors

Thanks for the tip about Replace, but we would like to use only one query with the cb_cursor, which would be simpler for upgrading ou users.

Do you have an idea why this cb_cursor script would fail ?
DELIMITER ##
#DROP PROCEDURE IF EXISTS curCbupdate;
CREATE PROCEDURE curCbupdate()
BEGIN
    DECLARE done INT DEFAULT 0;
    DECLARE username VARCHAR(255);
    DECLARE curSales CURSOR FOR SELECT `user_name` FROM `#__enmasse_sales_person` WHERE `user_name` = "[username]";
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
    
    OPEN curSales;
    
    read_loop: LOOP
    FETCH curSales INTO username;
    IF done THEN
      LEAVE read_loop;
    END IF;
	
    # UPDATE enmasse_sales_person
	IF LENGTH(username)>0 THEN
		UPDATE #__enmasse_sales_person SET `name` = "[name]",`address` = "[address]",`phone` = "[phone]",`email` = "[email]",`zip_code` = "[zipcode]",`city` = "[city]",`country` = "[country]", `updated_at` = NOW() WHERE `user_name` = username;
	ELSE IF
		INSERT INTO `#__enmasse_sales_person`(`name`,`user_name`,`address`,`phone`,`email`,`zip_code`,`city`,`country`,`published`,`created_at`,`updated_at`) VALUES ("[name]","[username]","[address]","[phone]","[email]","[zipcode]","[city]","[country]","1",NOW(),NOW());
	END IF;
    
    # UPDATE enmasse_merchant_branch
	IF LENGTH(username)>0 THEN
		UPDATE `#__enmasse_merchant_branch` SET `name` = '[name]',`branches` = '{"branch1":{"branchname":"branch1","name":"[name]","description":"","google_map_width":"200","google_map_height":"200","address":"[address]","telephone":"[phone]","fax":"[fax]","google_map_lat":"","google_map_long":"","google_map_zoom":""}}' WHERE `user_name` = username;
	ELSE IF
		INSERT INTO `#__enmasse_merchant_branch`(`name`,`user_name`,`sales_person_id`,`branches`,`zip_code`,`city`,`country`,`published`,`created_at`,`updated_at`) VALUES ('[name]','[username]',(SELECT `id` FROM `#__enmasse_sales_person` WHERE `user_name` = '[username]'),'{"branch1":{"branchname":"branch1","name":"[name]","description":"","google_map_width":"200","google_map_height":"200","address":"[address]","telephone":"[phone]","fax":"[fax]","google_map_lat":"","google_map_long":"","google_map_zoom":""}}','[zipcode]','[city]','[country]','1',NOW(),NOW());
	END IF;
    
    # UPDATE user_usergroup_map
	IF (SELECT COUNT(`group_id`) FROM `#__user_usergroup_map` WHERE `user_id` = '[user_id]') < 2 THEN
		DELETE FROM `#__user_usergroup_map` WHERE `user_id` = '[user_id]';
	END IF;
	
    INSERT INTO `#__user_usergroup_map`(`user_id`,`group_id`)
    VALUES
    ('[user_id]', (SELECT `merchant_group` FROM `#__enmasse_setting`)),
    ('[user_id]', (SELECT `sale_group` FROM `#__enmasse_setting`));
    
    END LOOP;
    
    CLOSE curSales;
END;

CALL curCbupdate;

Please Log in to join the conversation.

12 years 5 months ago #183003 by krileon

Thanks for the tip about Replace, but we would like to use only one query with the cb_cursor, which would be simpler for upgrading ou users.

Do you have an idea why this cb_cursor script would fail ?

I've no experience with procedures so can't comment on whether it'll work or not and why it's failing. Very likely it won't work with the substitutions. Please test the query I provided in my previous post and confirm if working or not.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

12 years 5 months ago - 12 years 5 months ago #183007 by activha
Well I tested the queries both with INSERT INTO then with REPLACE and nothing works, still same error as before.
I also tried to split the queries in 3 different fields in mysql integration but same error again when applying the plan

Further we checked the cb cursor script two posts above and it seems well written. This is crazy that this could not be included in the mysql queries integration.

Maybe another bug ? or problem somewhere in cbsubs to correct ?

Please Log in to join the conversation.

12 years 5 months ago #183011 by krileon
The queries I've provided should be fine, but of course aren't going to work as you've a fatal error in the storing process of a user. Please PM backend super administrator login credentials and will take a look.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.223 seconds

Facebook Twitter LinkedIn