Conditional Calculations for field entries within Wordpress using PHP - php

I was wondering if anyone with some experience with PHP could help. I've been trying to figure out if there is a way within WordPress (GravityView) to make calculations based on certain entries within a form and then use conditional logic to display different images dependent on the result from this calculation.
In this case, I am trying to display different images relating to different measures of a client, i.e. their value to our company, their engagement with our company. Taking the example of Satisfaction I have added a field to one of our forms where if a request is completed unsuccessfully with them it will count that entry. However, I then need to sum all these unsuccessful entries so I can relate them to the different levels of satisfaction (the images). i.e if there are 10 unsuccessful entries for a given client they will be given a poor level of satisfaction and if there are 0 they would be given an excellent level of satisfaction. This is not possible to do within a view in gravity view as you cannot use a shortcode within a shortcode. I cannot sum all the entries using [gvmath] for a specific field and then use [gvlogic] to assign the different levels to different images. So I was wondering if there is a way to bypass this by issue by writing the code directly in PHP.
Also, another issue is within the form that is used for the requests there is a field where the member ID is inserted. Each of our individual clients is given a specific member ID and then a page is created for that client where their 'Levels' are displayed. So ideally the PHP code would be able to sum the entries for only that specific member ID and then using the result of that calculation assigns a particular image to it depending on the answer. Is this all getting too complicated and not able to be performed within WordPress? I've been trying to wrap my head around it all week so any help would be greatly appreciated.
I've attached a picture of the specific images that I would like to assign to the different levels.
Let me know if any further context to my issue is required.
Thanks :)
Levels

Related

The best way to display item's specification on item page for Google's better indexing

As I've heard site with more Google's index has more chance to show better results
i wrote my own CMS
my site structure like this
index.php, itempage.php and insertitem.php [and some anothers that not important]
users insert item by fill insertitem.php
those items shows on index page
visitor user select item from index page and its call itempage.php?item_id=[id]
and this page show item properties
But this will cause the number of pages indexed to be limited to several numbers, despite the large number of products.
This method leads to a small number of Google indexes
no problem?
It is not better to create a html page in the server side when inserting the items's properties by using the php code. To be indexed by Google separately?
Thanks

Display column-based instead of Row-Based records in PHPMaker 10

I'm having trouble and I wanna ask, if it's possible to have column-based tables when PHPMaker generates tables for records? Because when I generate it only generates row-based records. Copy-paste the link below to URL to understand. I'm sorry I'm not knowledgeable in PHP that much. It's just very easy to make a complete application with this program and the only thing stopping me is the format of how it's shown. An example of how I wanted it to look like would be this one
I hope somebody answers! Thanking you all in advance!
That kind of column based view is not suggested as it has many flaws when we try to display huge number of records. Adding pagination or sorting feature is very difficult and not user friendly.
As you have so many fields you could try to group them into tabs by relevancy. Once you put them under different tabs they can be easily navigated and easily fit into row based structure.
Creating tabs is PHPMaker is very easy, on field configurations screen you will get Page No config next to each field. By default it set to 1 you can set required page number as per your choice. Once you done go to Table config of the table which is second tab available for each table. Scroll down to bottom and and click on 3 dots next to Page Labels config (Under Multi Page Config). This will pop up a screen where you can add captions for your tab.

Web App: Gathering unknown amount of data from user an unknown number of times

My Problem I am writing an app for internal use at my pharmacy. I am gathering some usage data from multiple pharmacy systems to help manage inventory. 95% of the records I can automatically parse how many tablets are used every day, but there are some that require user input. This input consists of 3 fields (date, time, number of tabs) for an unknown number of records. For example, twice a day would have 6 records for 3 days, whereas 3 times a day would have 9.
My Current Solution The user selects the records to process and starts the procedure. Any records that can be automatically processed are taken care of. Any records requiring user input are stuck in a table. Upon refresh of the page, an Ajax request checks the table for any records. If a record is present, a modal is shown to the user to allow their input. The input form has a "new record" button that shows another round of the 3 fields, then the data is POSTed to a php script. The script processes the data and removes the affected record. If multiple records, the ajax script pops another modal. This continues until the table is empty.
Help There has to be a more elegant solution out there. I've look at several CRUD grids, but most seem to be about showing and editing data, not about general data entry.
Sorry for the wall of text.
Do you mean something like this
http://www.labs.mimmin.com/inlineedit/
http://dev.iceburg.net/jquery/tableEditor/example_new.php
I found it on google by using 'jquery inline editable table'
I know Yii has a nice admin interface specifically fast input, but I sense you wrote the code yourself, transferring to Yii might be a bigger challenge that solving this in a nice way.
good luck

How to auto categorise user generated content

I have a system where the user makes a post, this post will include a title, and the post content itself, the content will be anywhere between 20 - 3000 words and consist of plain text.
I also have a set of more then 700 categories, some are top level categories, the rest are subcategories.
When the user enters the content for their post, they need to be prompted with up to 5 relevant categories, selected automatically based on what the user has typed in.
What is the best way to do this, I am using PHP & MySQL, links to any libraries or code samples would be useful.
User perspective
You cannot do this on 1 step in the same page with only php/mysql. There are mainly 2 options for your question.
You also learn/use some client-side language and implement it to do a search without changing the page. I don't know much of it, so I cannot really recommend anything specific, but this thread should help you.
You use a middle page. That said, the user posts it's content, then after sending it you parse it and offer categories for the user to select in the new page. This has the problem that many users might close the window after pressing 'send' in a comment as they expect it to be sent straight, the good thing is that it only uses php/mysql.
Parsing the text
Once again I'm not sure if this is the most efficient way, but I'd try this and keep testing until achieving the result expected:
First, create a list of few keywords for each category. 4 or 5 should do the trick, but it depends greatly on the categories, text and many other factors.
Then, create an array of 10 elements. 5 would be the id of the category and 5 would be the 'score' for each category. You can set, for example, a score of 1 for each keyword found. Remember to asign some values initially or you'll have nothing to compare it to.
Then I'd search each category keywords in the text. If you get an score superior than any of those obtained previously, substitute the minimum one for the new category.
Echo the 5 categories remaining at the end of the script. They should be the 5 more suitable. But keep in mind that there are many more ways to approach this parsing problem.

PHP : inheritance logical (extends)

This may sound as a non related coding question but it's directly related :
The facts: I've developped a website (with symfony) which allows players to search for a team (like a job board). It makes one module only.
The problems I want the website to be even more accurate and make a custom form for each players depending on the game (for example, for those who play "league of legends" they'll have 3 more informations to fill up....)
The solutions?
One module per game (example: http://pastie.org/private/cl48jsrjreukyjmj7jrk8a).
I'm currently developping 1 module per game in order to take in consideration the specific criteria for specific games.
Advantages :
The player enters the informations in relation with his game and does not see/interact the other criteria
Disavantages:
90% of the code are the same between each modules. It takes more time.
Inheritance
I never played with that before so i don't know if it's possible in my case to stick with 1 module for the entire game collection AND taking in consideration the specific criterias for games. In that case it would mean to have 1 template per game and displaying the right template with the right accessors like
($this->getCV()->getPseudo(); / $this->getCV()->getGame()->getSpecificCriteria1();)
If I have read your question correctly, you want to show additional fields for each specific game.
Solution 1
Create a 2 form process. After your first form, you could redirect the user to a second form which depends on their answers. To do this, in your first form, use a redirect to send the user to a game-specific second form.
Solution 2
Pass the name of the game to the template and show a customised partial for the extra form fields. For this you will need a Url with a game parameter like this:
www.example.com/form/show/:game_identifier
Then in your action, read the parameter and pass it to your template.
In the template, show a partial dependant on the game that was passed through. So only show the extra fields if a specific game was chosen before hand.
There are further ways to accomplish this but these 2 sprung to mind first.

Categories