We are beginning to allow multi-national registrations and have the requirement to split the phone number entry in the OnePage checkout billing.
We want to add Country Code and split the rest into Area Code Number and Extension fields. Then we will need to concatenate them into one before storing them.
How would I accomplish that?
Could you not just use a hidden field and javascript? So add 2 fields, then use onchange="phonecat()" on each to trigger a function that concatenates then values and assigns them to the pre-existing telephone field, which you have changed to be type="hidden".
Something like the following in JQuery:
function phonecat() {
$(function(){
newphone = jQuery("#initialphone").val() + jQuery("#latterphone").val();
jQuery("#billing\\:telephone").val(newphone);
}(this.jQuery));
}
I've not tested this exact solution, but I've used something similar in the cart. Only the (now hidden) proper field will be passed and used.
File is .../persistent/checkout/onepage/billing/phtml in 1.6 (without persistent/ earlier). And you'll need to define the function somewhere too.
Related
I have overridden the APPrintChecks data view to sort by Vendor Code. But since the client's VendorCodes are all numeric, they would like to see the checks sorted so that, for example, VendorCode '357' is printed before VendorCode '10021'.
Any ideas on how I can accomplish that?
public class APPrintChecks_Extension : PXGraphExtension<APPrintChecks>
{
//change sort from Vendor Name to Vendor Code
[PXFilterable]
public PXFilteredProcessingJoin<APPayment, PrintChecksFilter,
InnerJoin<Vendor, On<Vendor.bAccountID, Equal<APPayment.vendorID>>>,
Where<boolTrue, Equal<boolTrue>>,
OrderBy<Asc<Vendor.acctCD, Asc<APPayment.refNbr>>>> APPaymentList;
}
As per suggestion in the comments, I would first check if there is another numeric/date field you can sort on such as BAccountId or CreatedDate. If this will not do, you will need to find a more creative way to fix it such as:
Changing Vendor Code Numbering Sequence to include leading zeros,
example: 0000357, 001021
Adding a custom field (which is stored in the database) and setting this custom field in the graph to include the leading zeros. Example
add field UsrVendorCode of type string where you add the leading
zeros in an event (of the Vendor Graph) such as RowPersisting.
Adding a calculated database field to add leading zeros and adding this as a custom field (extension of Vendor) in Acumatica (not sure
whether this is fully supported by Acumatica since it requires
modifications in DB)
I am stuck on a problem that I did not think before.
I have a form formers with 3 fields (name, firstname, status).
Then, my second form is the trainings with 2 fields (date_sitting, fk_former).
Here, I have 1 sitting date -> 16/07/2019 and the former is Dujardin Luc.
Now my problem is that if I want to create a new sitting for on 18/07/2019.
How to do for that the former Dujardin Luc to be available in my dropdownlist for on 18/07/2019 or another date??
Is it, in my case, I must to create 2 files create.blade ?
The first will just have a field -> date_sitting
And the second form will have the field -> fk_former ?
Here is my TrainingController for information
public function index()
{
$trainings = Training::oldest()->paginate(5);
$formersNoTrainingToday = Training::whereDate('date_sitting', "!=", Carbon::today())
->orWhere('date_sitting', null)->get();
$formers = Former::doesntHave('trainings')->get();
return view('admin.trainings.index', compact('trainings'))
->with('i', (request()->input('page',1) -1)*5);
}
I can't give you the whole answer, as there are too many things to update and a few things to decide.
First, you'll need to change your index() method to both send more and different data. If a former can train on multiple days, the $formers = Former::doesntHave('trainings')->get(); is no longer valid -- you want all formers now so that you can add a new date. So just $formers = Former::get(); now.
Next, your $formersNoTrainingToday is now obsolete, as you don't want to identify those who are unavailable just today, you want a list of all training dates so compare against whatever date the user is looking for in the form. Example: If Dujardin Luc wants training on 18/07/20XX, we don't want him in a list of NoTraining because we want him available, even if he is unavailable today.
Last on the controller side, depending on how you want to do the blade side, you might want to include a variable for an AJAX date to use to send through those formers who are available on the specific date requested by the user through AJAX. For example, if you go through AJAX, you might have a method to just send those available on the date requested like this in your controller (Not exact code):
public function getFormersWithoutTrainingOnDateRequested($dateRequested){
$formersAvailableToday = Training::whereDate('date_sitting', "!=", Carbon::createFromFormat('Y-m-d', $dateRequested))
->orWhere('date_sitting', null)->get();
return json_encode($formersAvailableToday);
}
The next part is on the blade side. You have quite a few choices here, but both of the ones I recommend involve some type of JS or Jquery. In order to populate the list of formers for the day that the user requests, for best user experience, you should get them the list quickly.
Fastest would be to provide a list of trainings (date_sitting, fk_former) to the page from the index. This would be stored as a data-object on some element of the blade page. Then, when the user clicks to change the date, a JS or Jquery function would pull the list into a var, compare it against another list of former's ids stored the same way, and re-write the select list immediately, using only those formers whose ids were not matched for the date.
Second way to do this would be a little slower, but a little easier. It would involve going back to the server to get the list of formers available. So you would have an AJAX function on the same select that goes back to the server to pull those formers available on the date chosen. The success() method of the AJAX pull would provide the info to re-write the select box, or perhaps even re-make the whole form.
Sorry I can't write all the code, you'll have to fill in the blanks where you can, but this is hopefully enough to help you figure out where to go.
How might it be possible to get Commerce-Product-Display information in a Commerce-Order object?
The issue is I need to publish a Commerce-Product-Display node when a user has made a payment to publish the node. I am using Rules to detect the payment and attempt to publish the node.
My problem is, because the Completing the checkout process Rules event only has data for a Commerce-Order, and the Commerce-Order does not have information for the Product nor the Product display, I am unable to publish the node.
OK, so here's my new answer based on the new info you provided in your question
=================================
So this is probably a little more complicated than you expected, but not impossible! Two things are important:
the line-items that are attached to your order will contain your products and
you will need to use a rule component, in order to be able to have an additional 'condition-action' combo inside your rule action
Here is how to do it:
In your rule that is triggered upon 'Completing the checkout process', add a loop in your 'Actions' section. You should see 'Add loop' right next to 'Add action'. We'll use this loop to iterate through all the commerce-line-items in your order: that's where the products are hiding
When configuring the loop, tell it to iterate through 'commerce-order:commerce-line-items' and either rename, or remember what it's going to call each line item as it goes through it.
Now - as it's going through each of your order's line items, we'll want to call an entire new rule with its own set of 'condition' and 'action'. The condition we need is to check that the line item contains the product you expect, and the action can be whatever you want - publish a node based on a certain field or whatever. In my case, the action will just be sending an email to prove I found a product. When we need condition-action sets within a rule, we need to create a rule component!!
Go to /admin/config/workflow/rules/components to create a new rule component to run for each of the above items. Click the 'Add new component' link at the top of the page
Select 'Rule' from the drop-down options, since this will be a component that contains both a condition and an action
Name the rule, and in the 'Variables' section, we have to let it know we're going to pass it a parameter to work with. In our case, it will be the commerce line item that is currently being iterated through.
Add two conditions to your component (or whatever checks you think are necessary). I added 'Entity is of type' => Commerce Line item and 'Entity has field' => commerce_product. So this runs for all my products at the moment.
The condition I set on my component is to send an email, and I filled in the following for the body of the email: [line-item:commerce_product], and it prints out the product's name beautifully in the email each time I've tested checking out!
But first - how do I call this component for each of my line item types after I save it?? Read on:
After the component is saved, Add an action to your loop:
From now on, at the very bottom of your actions, you'll see a brand new 'Components' section, and in your case, you should only have one now. Select it to call it for each item:
Last step will be to fill in the parameter to pass to this component, which is obviously the list_item you're currently on, or whatever the computer name of the current item was if you changed it.
Save and test!
Whew! It's a little complicated, but I hope it puts you in the right direction!
The way rules work in Drupal is that not all fields are shown for your entity by default in the actions. What you need to do is prompt Rules to recognize your object as a certain type of node in order for the Rule to add all of its appropriate fields.
You can do this either by
using the 'Content is of type' under the Node section check (and select your Commerce Display node type or
directly using the 'Entity has field' check under the Entities section to check for a specific field you want to use.
Either of those should prompt Rules to recognize the type of entity you're working with and populate the Actions with the necessary fields.
Let us know if this works!
I'm building a CRM solution for a customer to replace their legacy Access databases. They have cases with case numbers that are referenced by external documents and want to keep them as the case number in CRM. I wrote a plugin that auto-increments and assigns case numbers when new cases are created and it works great. The problem is when I try to import their old data. I map their old case number field to the case number field in the import wizard but the imported cases get a new case number like PRE-12345-asdf.
Case number can't be updated by a workflow.
Ideally I'd like to be able to use the built in case number, but would I be losing out on any functionality if I just hid the built in case number field and added a custom field for it?
You can create a custom field to track your own Case Number instead (in this case we just called it "casenumber").
On the Case Entity form onLoad event we put the following function that updates the Case Number shown in the Header area as well as the Page/Tab title to be our custom field:
function UseCustomCaseNumber()
{
var caseNumber = Xrm.Page.getAttribute("new_casenumber").getValue();
document.getElementById('form_title_div').childNodes[2].innerHTML = caseNumber;
parent.document.title = "Case: " + caseNumber + " - Microsoft Dynamics CRM";
}
The built-in case number cannot be overwritten. Hiding it and using your own field seems relatively common, and won't cause you any issues.
How do I tell the Zend_Form that I want an element (and it's ID-label, etc) to use another ID value instead of the element's name?
I have several forms in a page. Some of them have repeated names. So as Zend_Form creates elements' IDs using names I end up with multiple elements with the same ID, which makes my (X)HTML document invalid.
What is the best solution to fix this, given that I really have to stick with using the same element names (they are a hash common to all forms and using the Zend_Form Hash Element is really out of question)?
Zend_Form_Element has a method called setAttribs that takes an array. You may be able to do something like $element->setAttribs(array('id' => "some_id"));
or you can do $element->setAttrib('id', 'some_id');
Thanks, Chris Gutierrez.
However, as I said, I needed to get ride of the default decorator generated IDs like -label. Wiht the $element->setAttribs() it is not possible, however.
So based on http://framework.zend.com/issues/browse/ZF-7125 I just did the following:
$element->clearDecorators();
$element->setAttrib('id', 'some_id');
$element->addDecorator("ViewHelper");
Whoever sees this: please note this was enough for what I needed. But may not be for you (the default settings has more than the viewHelper decorator).