Integrations Tab Ifs or switch

12 years 11 months ago - 12 years 11 months ago #159941 by popROAR
Integrations Tab Ifs or switch was created by popROAR
Hello,

I am unable to locate some information on how or where I may want to integrate a field setting. This may be possible with CB by itself? I am looking for a solution to set a field based on a string of another field

for example:
if (field_name == A,B, or C)
         new_field_name = Monday;
else if (field_name == D,E,F)
         new_field_name = Tuesday;
else 
         new_field_name = Error?;


As you can see I am working with dates, basically setting zip to day of week.
I did find 155200-cb-is-updating-josusers-after-sql-action where they are having trouble with zipcode and I guess I do not know what is going on.
Furthermore I would think I could do this with a Field Integrations plug-in?

Then I would also like to take this Day of week and match it to an active/inactive(on hold) status and match the field
if(status != inactive) //postponed || inactive - based on selected dates (vacation)
if (fieldtypeFrequency == A)
    new_date_field = "this " new_field_name (as date);
else if(fieldtypeFrequency == B)
    new_date_field = "next " new_field_name (as date);
else
    new_date_field = 4 weeks + new_field_name (as date);
else 
    new_date_field = new_field_name (as date) > return_date_field; 
                                                         // next valid date post-marked


I am beginner C++ , SQL HTML programmer trying to figure out how to play in Joomla using CB.

Please Log in to join the conversation.

12 years 11 months ago #160174 by krileon
Replied by krileon on topic Re: Integrations Tab Ifs or switch
Don't understand what you're trying to do exactly and how it relates to CBSubs. Currently CBSubs does not have any API available. All of CBSubs switches for integrations tabs are done via XML.


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 11 months ago - 12 years 11 months ago #160256 by popROAR
Replied by popROAR on topic Re: Integrations Tab Ifs or switch
I want to create a field that is constantly updated.
I understand using [cb:if cb_day="Wednesday"] Congratulations [cb_username], you are Wed delivery! [/cb:if]​​​​​​​​​​​​​​​​​​​​ but am unsure how to set date values.

I want to make a conditional read-only field for the profile.
Then if they belong to a group A, B, or C another field updates the future date such as group A is every 1 week
group B is every 2 weeks
group C is every 4 weeks

Field title: Next Delivery
Field value: as DATE -
[cb:if cb_group="A" && cb_postpone="(a past date)"]longdate [cb_day] = dd [/cb:if]
[cb:if cb_group="A" && cb_postpone="(a future date)"]longdate [cb_day] = dd [/cb:if]

I found I can write an if statement as [cb:if cb_value="Value"]output[/cb:if]but that is all.

I tried doing this as a subscription period but it was difficult to set up a postpone period and specific end date so I set these groups as lifetime memberships. Now the customer can make adjustments without having to post a payment everytime and I only have to figure out how to get the CBSubs to post to Authorize.Net CIM.

My memberships or subscriptions are not necessarily for site permission/access(yet) but a scheduled delivery basket.

I would like to have a delimiter field in the user status that displays the php-
as
<?php
$frequency = 1;						//user preference 1 = every week 2 = every other week
$deliverday = 3;
echo "Your delivery day is ".date("l", $deliveryday); 	// equal to cb_zip switch case
echo "<br/>";
$today = time();
echo "Today is ".date("l F jS", $today);
echo "<br/>";
$postpone = mktime(0,0,0,date("3"),date("13"),date("Y"));	//equal to cb_postpone date field ?? getdate?
echo "The day you postponed (or signed up on) is ".date("l F jS", $postpone);
echo "<br/>";
if ($today < $postpone)
	$today = $postpone; 				//sets function below to future date if need else runs as today

if (date("w",$today) > $deliverday)
	$bump = date("w",$today); 			//difference to next week
else if (date("w",$today) < $deliverday)
	$bump = ($deliverday - date("w",$today));	//difference for this week
else
	$bump = 0;					//equal
	
if ($frequency == 2 && $today > $postpone && date("W", $postpone)%2 != date("W", $today)%2 )
	$bump += 7;					//if alternating weeks checks even/odd
	
$nextdelivery = ($bump * 24 * 3600)+ date($today); 

echo " so your next delevery day should be ".date("l F jS", $nextdelivery);
?>

not word for word but this might show what I am trying to do.
If i can figure out how to use the cb_field value_as_date to use these algorithms in the delimiter field I might figure it out.

Please Log in to join the conversation.

12 years 11 months ago #161113 by krileon
Replied by krileon on topic Re: Integrations Tab Ifs or switch
What you're wanting is probably best done using PHP in a new fieldtype so you can ensure accuracy. Alternatively you can use incubator project CB Query Field which takes a database query and displays its results as a field. What you'd do in this query is do your date calculation as using MYSQL functions you can actually return the day of the week the date supplied is. Then all you need to do is substitution in that CB Query Field.

As for displaying what the current datetime is if using CB 1.4 you can use the new date substitution. Please see tutorials within my signature for substitution usage details (date substitution usage provided).


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.
The following user(s) said Thank You: popROAR

Please Log in to join the conversation.

12 years 11 months ago #161737 by popROAR
Replied by popROAR on topic Re: Integrations Tab Ifs or switch

What you're wanting is probably best done using PHP in a new fieldtype so you can ensure accuracy.


I saw your tuts and am in the works to put this in my own module but as I quoted, that is what I would rather accomplish. How do I add php to a new field type? I didn't think I can use php in my editor.

Please Log in to join the conversation.

12 years 11 months ago #161775 by krileon
Replied by krileon on topic Re: Integrations Tab Ifs or switch
You don't add PHP to a fieldtype, you create a new fieldtype. This is done by way of a new CB plugin. For working examples please see ajax text and file fieldtype plugins. Suspecting it'd just be easier to use CB Query Field incubator project and substitutions.


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.211 seconds

Facebook Twitter LinkedIn