Custom round off logic

One of my customers is asking for the following rounding logic. Want to check if there is anyway straightforward way of doing this in SQL.

0 to 0.49 – round to 0
0.5 to 0.54 – round to 0.50
0.55 to 1.00 – round to 1.00

Thank

9 – How do I connect to a database while building a custom module?

9 – How do I connect to a database while building a custom module? – Drupal Answers

How to connect to a mysql/mariadb database in Drupal 9 while building a custom module

Are you pulling data with AJAX or plain , entity_field ?

Again, is the pulled data being implemented in entity, node or block .

Now comes – database API, add some code which API you seem, not working in Drupal-9.

The database API, working version – As documented by Drupal Official Documentation –
Drupal Database API and Drupal 8 dynamic query

Unless you required to do do not use full query as Verbatim, instead use Drupal API,

Drupal API based Select query

Drupal::service('database')->select('users', 'u');
 
  ->condition('u.uid', 0, '<>')
  ->fields('u', ('uid', 'name', 'status', 'created', 'access'))
  ->range(0, 50);

The Drupal::service('database') can be Drupal::database.

When, this API is not working, you can write in Native PHP, and get the Array or Object, you have stored.

Your question is incomplete to understand. Yes, sometimes the insert or select and merge even update API is hard to get worked. insert or update will not fail you.

But merge is hard to get work, sometimes – select can fail.

magento2 – Strange design problem in checkout custom step

I have added a new checkout step which appears this way:

enter image description here

Please note the horizontal line.

By inspecting, I see a ::before pseudoelement:

enter image description here

That pseudoelement is responsible that line to be displayed.

When I go to that tab, it is displayed as this:

enter image description here

The pseudoelement does not appear at this time:

enter image description here

What may be causing that pseudoelement to be inserted?

This is the actual HTML template of the step:

<li id="extra_info" data-bind="fadeVisible: visible()">
    <div class="step-title" data-bind="i18n: 'Datos de Facturación'" data-role="title"></div>
    <div id="checkout-step-extra"
         class="step-content checkout-shipping-method"
         data-role="content">

        <form id="extra-form" class="form" data-bind="submit: navigateToNextStep" novalidate="novalidate">
            <div id="billing-form" class="billing-info fieldset" data-role="content">
                <!-- ko foreach: getRegion('extra-fieldsets') -->
                <!-- ko template: getTemplate() --><!-- /ko -->
                <!--/ko-->
            </div>
            <div class="actions-toolbar">
                <div class="primary">
                    <button data-role="opc-continue" type="submit" class="button action continue primary">
                        <span><!-- ko i18n: 'Next'--><!-- /ko --></span>
                    </button>
                </div>
            </div>
        </form>
    </div>
</li>

Any help? I want to avoid doing a trick to hide that line by mean of a custom CSS.

magento2 – Custom form in checkout process is not validated

I have created a new checkout step between shipping address step and payment step. Inside it, I have added a new form.

That step has the Next button. When I press that button, the form is not validated. How can I do it?

This is the step template:

<li id="billing_info" data-bind="fadeVisible: isVisible">
    <div class="step-title" data-bind="i18n: 'Datos de Facturación'" data-role="title"></div>
    <div id="checkout-step-billing"
         class="step-content checkout-shipping-method"
         data-role="content">

        <form class="form" data-bind="submit: navigateToNextStep" novalidate="novalidate">
            <div id="billing-form" class="billing-info fieldset" data-role="content">
                <!-- ko foreach: getRegion('billing-form-container') -->
                <!-- ko template: getTemplate() --><!-- /ko -->
                <!--/ko-->
            </div>
            <div class="actions-toolbar">
                <div class="primary">
                    <button data-role="opc-continue" type="submit" class="button action continue primary">
                        <span><!-- ko i18n: 'Next'--><!-- /ko --></span>
                    </button>
                </div>
            </div>
        </form>
    </div>
</li>

Note where the new form fields are placed.

This is the JS that controls the step:

define((
    'ko',
    'uiComponent',
    'underscore',
    'Magento_Checkout/js/model/step-navigator'
), function (ko, Component, _, stepNavigator) {
    'use strict';

    /**
     * mystep - is the name of the component's .html template,
     * <Vendor>_<Module>  - is the name of your module directory.
     */
    return Component.extend({
        defaults: {
            template: 'MyVendor_Checkout/billing-step'
        },

        // add here your logic to display step,
        isVisible: ko.observable(true),

        /**
         * @returns {*}
         */
        initialize: function () {
            this._super();

            // register your step
            stepNavigator.registerStep(
                // step code will be used as step content id in the component template
                'billing_info',
                // step alias
                null,
                // step title value
                'Billing Info',
                // observable property with logic when display step or hide step
                this.isVisible,

                _.bind(this.navigate, this),

                /**
                 * sort order value
                 * 'sort order value' < 10: step displays before shipping step;
                 * 10 < 'sort order value' < 20 : step displays between shipping and payment step
                 * 'sort order value' > 20 : step displays after payment step
                 */
                15
            );

            return this;
        },

        /**
         * The navigate() method is responsible for navigation between checkout steps
         * during checkout. You can add custom logic, for example some conditions
         * for switching to your custom step
         * When the user navigates to the custom step via url anchor or back button we_must show step manually here
         */
        navigate: function () {
            this.isVisible(true);
        },

        /**
         * @returns void
         */
        navigateToNextStep: function () {
           stepNavigator.next();
        }
    });
});

And this the JS that controls the form:

define((
    'Magento_Ui/js/form/form'
), function(Component) {
    'use strict';
    return Component.extend({
        initialize: function () {
            this._super();
            // component initialization logic
            return this;
        },

        /**
         * Form submit handler
         *
         * This method can have any name.
         */
        onSubmit: function() {
            // trigger form validation
            this.source.set('params.invalid', false);
            this.source.trigger('billingForm.data.validate');

            // verify that form data is valid
            if (!this.source.get('params.invalid')) {
                // data is retrieved from data provider by value of the customScope property
                var formData = this.source.get('billingForm');
                // do something with form data
                console.dir(formData);
            }
        }
    });
});

Should I add the code of the last JS as part of the first JS? Should I extend Magento_Ui/js/form/form there?

Please, can you give me a hand?

[WTS] KVM SSD VPS ⚡ Linux & Windows RDP ⚡ Custom ISO ⚡ Unmetered 1 Gbps Bandwidth ⚡


KVM VPS Sale @ Veeble Hosting –
Flat 20% Discount
————————————————————————————————————————————–

KVM VPS

  • Starting from $8.5 per month
  • Unmetered 1000 Mbps bandwidth
  • FREE Basic Management on all Plans
  • Dedicated Resources
  • Smart Control Panel with Shutdown, Boot, Reboot, Re-install and console access.
  • Instant Setup
  • US located servers
  • RAID-10 SSD Storage
  • Linux & Windows OS
  • Custom ISO Load on request

Order KVM VPS here https://www.veeble.org/vps/kvm

————————————————————————————————————————————————————————————————————————
We accept the following payment methods

  • PayPal
  • Skrill
  • All Major International Credit Cards
  • Perfectmoney
  • Payeer
  • Bitcoin, Ethereum, Litecoin, Ripple, Tether, Dogecoin
  • All Indian Credit/Debit cards and Netbanking
  • Webmoney
  • Paysafecard
  • Alipay
  • Tenpay
  • QIWI
  • Local Bank transfer in US, UK
  • SEPA Transfer
  • Wire/Swift Transfer

Know more about the payment methods here – https://www.veeble.org/how-to-pay
(COLOR=#000000)(FONT=Tahoma)
(/FONT)(/COLOR)(COLOR=#000000)(FONT=Tahoma)————————————————————————————————————————————————————————————————————————(/FONT)(/COLOR)(COLOR=#000000)(FONT=Tahoma)

Our Support

(/FONT)(/COLOR)We tirelessly work around the clock to ensure top notch support and a wonderful customer experience.
You can contact us through

  • Email/tickets (24×7)
  • Live Chat (24×7)

(COLOR=#000000)(FONT=Tahoma)

(/FONT)(/COLOR)(COLOR=#000000)(FONT=Tahoma)————————————————————————————————————————————————————————————————————————(/FONT)(/COLOR)(COLOR=#000000)(FONT=Tahoma)

(/FONT)(/COLOR)(COLOR=#000000)(COLOR=#000000)(FONT=verdana)(FONT=verdana)(FONT=verdana)Connect with us through (/FONT)(COLOR=#000000)(COLOR=#000000)(FONT=verdana)social networks(/FONT)(/COLOR)(/COLOR)

(/FONT)(/FONT)(/COLOR)(/COLOR)(COLOR=#000000)(COLOR=#000000)(FONT=verdana)(FONT=verdana)(COLOR=#000000)(COLOR=#000000)(FONT=verdana)Twitter: (/FONT)(/COLOR)(/COLOR)www.twitter.com/veeble
(COLOR=#000000)(COLOR=#000000)(FONT=verdana)Facebook: (/FONT)(/COLOR)(/COLOR)www.facebook.com/veeble
(COLOR=#000000)(COLOR=#000000)(FONT=verdana)LinkedIn: (/FONT)(/COLOR)(/COLOR)www.linkedin.com/company/veeble
Instagram: www.instagram.com/veeble

If you have any questions please log on to (/FONT)(/COLOR)(/COLOR)http://veeble.org/support

.(tagsToTranslate)webmaster forum(t)internet marketing(t)search engine optimization(t)web designing(t)seo(t)ppc(t)affiliate marketing(t)search engine marketing(t)web hosting(t)domain name(t)social media

Enable comments for custom template page

We use careerfy theme WordPress which is a system for a job board.

I would like to enable comments for each job post page, these pages are not listed on the WordPress admin panel, I can access it via child theme only, in this path:
(wp-content/themes/careerfy-child-theme/wp-jobsearch/detail-pages/job/view3-job.php)

I have tried to add a shortcode but it seems not working.

custom field – How to make a complete Meta Box part of a complete Post Type?

I receive the code complete, but I don’t know how to make the Post Type loads the MetaBox when creating a new Post, here is the Post Type:

if ( ! function_exists('cpt_campaign_details') ) {

// Register Custom Post Type
function cpt_campaign_details() {

    $labels = array(
        'name'                  => _x( 'Campaign Details', 'Post Type General Name', 'text_domain' ),
        'singular_name'         => _x( 'Campaign Detail', 'Post Type Singular Name', 'text_domain' ),
        'menu_name'             => __( 'Campaign Details', 'text_domain' ),
        'name_admin_bar'        => __( 'Campaign Detail Post', 'text_domain' ),
        'archives'              => __( 'Campaign Details Archives', 'text_domain' ),
        'attributes'            => __( 'Campaign Detail Attributes', 'text_domain' ),
        'parent_item_colon'     => __( 'Parent Campaign Detail:', 'text_domain' ),
        'all_items'             => __( 'All Campaign Details', 'text_domain' ),
        'add_new_item'          => __( 'Add New Campaign Detail', 'text_domain' ),
        'add_new'               => __( 'Add New', 'text_domain' ),
        'new_item'              => __( 'New Campaign Detail', 'text_domain' ),
        'edit_item'             => __( 'Edit Campaign Detail', 'text_domain' ),
        'update_item'           => __( 'Update Campaign Detail', 'text_domain' ),
        'view_item'             => __( 'View Campaign Detail', 'text_domain' ),
        'view_items'            => __( 'View Campaign Detail', 'text_domain' ),
        'search_items'          => __( 'Search Campaign Details', 'text_domain' ),
        'not_found'             => __( 'Not found', 'text_domain' ),
        'not_found_in_trash'    => __( 'Not found in Trash', 'text_domain' ),
        'featured_image'        => __( 'Featured Image', 'text_domain' ),
        'set_featured_image'    => __( 'Set featured image', 'text_domain' ),
        'remove_featured_image' => __( 'Remove featured image', 'text_domain' ),
        'use_featured_image'    => __( 'Use as featured image', 'text_domain' ),
        'insert_into_item'      => __( 'Insert into Campaign Detail', 'text_domain' ),
        'uploaded_to_this_item' => __( 'Uploaded to this Campaign Detail', 'text_domain' ),
        'items_list'            => __( 'Campaign Details list', 'text_domain' ),
        'items_list_navigation' => __( 'Campaign Details list navigation', 'text_domain' ),
        'filter_items_list'     => __( 'Filter Campaign Details list', 'text_domain' ),
    );
    $args = array(
        'label'                 => __( 'Campaign Detail', 'text_domain' ),
        'description'           => __( 'This post is used to manage all Campaign details', 'text_domain' ),
        'labels'                => $labels,
        'supports'              => array( 'title', 'thumbnail', 'page-attributes' ),
        'taxonomies'            => array( 'category', 'post_tag' ),
        'hierarchical'          => true,
        'public'                => true,
        'show_ui'               => true,
        'show_in_menu'          => true,
        'menu_position'         => 5,
        'menu_icon'             => 'dashicons-megaphone',
        'show_in_admin_bar'     => true,
        'show_in_nav_menus'     => true,
        'can_export'            => true,
        'has_archive'           => true,
        'exclude_from_search'   => false,
        'publicly_queryable'    => true,
        'capability_type'       => 'page',
    );
    register_post_type( 'campaign_details', $args );

}
add_action( 'init', 'cpt_campaign_details', 0 );

}

And here is the Meta Box:

class CampDeta_Resu {

    public function __construct() {

        if ( is_admin() ) {
            add_action( 'load-post.php',     array( $this, 'init_metabox' ) );
            add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
        }

    }

    public function init_metabox() {

        add_action( 'add_meta_boxes',        array( $this, 'add_metabox' )         );
        add_action( 'save_post',             array( $this, 'save_metabox' ), 10, 2 );

    }

    public function add_metabox() {

        add_meta_box(
            'CampDeta_Resu',
            __( 'Campaign Details Results', 'text_domain' ),
            array( $this, 'render_metabox' ),
            'post',
            'normal',
            'default'
        );

    }

    public function render_metabox( $post ) {

        // Retrieve an existing value from the database.
        $cade_re_results_numbers = get_post_meta( $post->ID, 'cade_re_results_numbers', true );
        $cade_re_results_legend = get_post_meta( $post->ID, 'cade_re_results_legend', true );

        // Set default values.
        if( empty( $cade_re_results_numbers ) ) $cade_re_results_numbers = '';
        if( empty( $cade_re_results_legend ) ) $cade_re_results_legend = '';

        // Form fields.
        echo '<table class="form-table">';

        echo '  <tr>';
        echo '      <th><label for="cade_re_results_numbers" class="cade_re_results_numbers_label">' . __( 'Number', 'text_domain' ) . '</label></th>';
        echo '      <td>';
        echo '          <input type="text" id="cade_re_results_numbers" name="cade_re_results_numbers" class="cade_re_results_numbers_field" placeholder="' . esc_attr__( '', 'text_domain' ) . '" value="' . esc_attr( $cade_re_results_numbers ) . '">';
        echo '          <p class="description">' . __( 'This is the number that will appear over the legend. Example: 5.4M | 8.4M+ | 5x', 'text_domain' ) . '</p>';
        echo '      </td>';
        echo '  </tr>';

        echo '  <tr>';
        echo '      <th><label for="cade_re_results_legend" class="cade_re_results_legend_label">' . __( 'Legend', 'text_domain' ) . '</label></th>';
        echo '      <td>';
        echo '          <input type="text" id="cade_re_results_legend" name="cade_re_results_legend" class="cade_re_results_legend_field" placeholder="' . esc_attr__( '', 'text_domain' ) . '" value="' . esc_attr( $cade_re_results_legend ) . '">';
        echo '          <p class="description">' . __( 'This text will go below the number and will define what the number means. Example: Total print reach | Visits | Engagement growth', 'text_domain' ) . '</p>';
        echo '      </td>';
        echo '  </tr>';

        echo '</table>';

    }

    public function save_metabox( $post_id, $post ) {

        // Sanitize user input.
        $cade_re_new_results_numbers = isset( $_POST( 'cade_re_results_numbers' ) ) ? sanitize_text_field( $_POST( 'cade_re_results_numbers' ) ) : '';
        $cade_re_new_results_legend = isset( $_POST( 'cade_re_results_legend' ) ) ? sanitize_text_field( $_POST( 'cade_re_results_legend' ) ) : '';

        // Update the meta field in the database.
        update_post_meta( $post_id, 'cade_re_results_numbers', $cade_re_new_results_numbers );
        update_post_meta( $post_id, 'cade_re_results_legend', $cade_re_new_results_legend );

    }

}

new CampDeta_Resu;

I googled “add a created metabox to a post type” and a lot of things like that and there is a lot of tutorials but unfortunately I can’t make it work.

gui – Custom C++ wxWidget Ranged Slider

I wanted to make a bounded slider since the ranged slider wxwidgets includes isnt very useful for my use cases. I got a good head start from a person who made a library in Python and ended up creating my own version in C++. I would appreciate any feedback on how I can improve my code or any errors I might have missed.

Using the widget requires wxWidgets 3.1.4; code can be found here https://github.com/georgeplusplus/wxWidgets-Custom-Ranged-Slider

Looking for feedback how to improve my code .

Tested to work with a bare MainWindow object that has the following:

#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif // !WX_PRECOMP

#include "include/MainWindow.h"
#include "include/RangeSlider.h"

MainWindow::MainWindow(wxWindow* parent,
    wxWindowID id,
    const wxString& title,
    const wxPoint& pos,
    const wxSize& size,
    long style,
    const wxString& name) :
    wxFrame(parent, id, title, pos, size, style, name)
{
    SetSize(300, 100);

    wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
    SetSizer(mainSizer);
    
    RangeSlider* range_slider = new RangeSlider(this);

    mainSizer->Add(range_slider, 1,  wxEXPAND | wxALL, 6);
    
}

enter image description here

How to return user email from a custom column “Owner” to an XML from sharepoint online list using CSOM?

How to return user email from a custom column “Owner” to an XML from sharepoint online list using CSOM?
This works but bug exists as it sends Microsoft.SharePoint.Client.FieldUserValue() instead of sending user name /email. Please help with this bug

string xmlFile = @"c:tempexport.xml";
Web web = clientContext.Web;
                    ListCollection listColl = web.Lists;
                    List list = clientContext.Web.Lists.GetByTitle("Site Pages");
                    clientContext.Load(list);
                    FieldCollection listFields = list.Fields;
                    clientContext.Load(listFields);
                    clientContext.Load(listColl);
                    clientContext.ExecuteQuery();

                    ListItemCollection listItems = list.GetItems(CamlQuery.CreateAllItemsQuery());
                    clientContext.Load(listItems);
                    clientContext.ExecuteQuery();

                    XmlDocument doc = new XmlDocument();
                    XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "ISO-8859-1", null);
                    doc.AppendChild(declaration);
                    XmlElement root = doc.CreateElement("SitePages"); //CREATES FIRST ROOT NODE
                    

                    foreach (ListItem item in listItems)
                    {

                       


                        ListItem LItem = listItems.GetById(item.Id);
                        XmlElement elem = doc.CreateElement("List"); //CREATES CHILD NODE
                        

                        elem.SetAttribute("DateLastReviewed", Convert.ToString(item("DateLastReviewed")));
                        elem.SetAttribute("NextReviewDate", Convert.ToString(item("NextReviewDate")));
                        elem.SetAttribute("ContentOwner", Convert.ToString(item("Owner")));                   // bug exists as it sends Microsoft.SharePoint.Client.FieldUserValue() instead of sending user name /email
                        elem.SetAttribute("ContentNumber", Convert.ToString(item("ContentNumber")));                       
                        elem.SetAttribute("ID", Convert.ToString(item.Id));
                        root.AppendChild(elem);

                    }
                    doc.AppendChild(root);
                    doc.Save(xmlFile);
                    Console.WriteLine(" XML file is successfully generated");
                    Console.ReadKey();
                }

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies 5000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive.com Proxies-free.com New Proxy Lists Every Day Proxies123.com Buy Cheap Private Proxies; Best Quality USA Private Proxies