Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexander Suvorov MasterHans

  • Russia
View GitHub Profile
View GeneralLedgerSettlementsProvider.php
$this->criteria->params[':cli'] = $this->clientId;
$this->criteria->params[':cor'] = $this->correspondenceAccountId;
$this->criteria->params[':cdi'] = $this->creditDebitIndicator == 'K' ? 'D' : 'K'; // Invert logic
$this->criteria->params[':invcdi'] = $this->creditDebitIndicator;
$this->criteria->order = 'd_data ASC, d_dok ASC';
View AngularJs: send-manager.controller.js
c.sendEmail = function () {
c.savingData = true;
if (_.isUndefined(c.model.toEmail) && model.templateId === 7) {
if (model.agreementIds.length === 1 && model.agreementIds[0] === 0) {
//get all employees
personnelEmployee.fetchAllWorkingEmployees()
.then(function (data) {
console.log(data);
prepareAndSend();
})
View WooComerce - add snipet to e-mail template
// add text to template in woocommerce_email_before_order_table hook
function filter_woocommerce_email_before_table( $order, $is_admin_email ) {
// make filter magic happen here...
echo '<h1><strong>Discount used </h1>';
};
add_action( 'woocommerce_email_before_order_table', 'filter_woocommerce_email_before_table', 10, 3 );
@MasterHans
MasterHans / AngularJs - Get input by angular.element
Created Jun 21, 2022
AngularJs - Get input by angular.element
View AngularJs - Get input by angular.element
var myElement = angular.element($document[0].querySelector('.form-control.input-sm.ng-valid.ng-not-empty.ng-dirty.ng-valid-parse.ng-touched'));
myElement.trigger('hideCalendar.daterangepicker');
@MasterHans
MasterHans / Wordpress - switch on log writing
Created Jun 19, 2022
Wordpress - switch on log writing
View Wordpress - switch on log writing
/**
* enable log writing
* // Enable WP_DEBUG mode
define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
*/
if (!function_exists('write_log')) {
@MasterHans
MasterHans / woocomerce - add validation on checkout field blur - out of input in JS
Created Jun 19, 2022
woocomerce - add validation on checkout field blur - out of input in JS
View woocomerce - add validation on checkout field blur - out of input in JS
add_action( 'wp_footer', 'ybc_javascript_validation' );
function ybc_javascript_validation(){
if( !is_checkout() ) return;
?> <script>jQuery(function($){
$('body').on('blur change', '#billing_birthday', function(){
// alert($(this).val());
var formRow = $(this).parents('.form-row');
// if( /\d/.test( $(this).val() ) ) {
View Woocomerce - get variation name of cart item
add_filter( 'woocommerce_checkout_fields', 'pulse_checkout_fields_validate_birthdate', 9999 );
function pulse_checkout_fields_validate_birthdate( $fields ) {
$cart = WC()->cart->get_cart();
foreach ( $cart as $cart_item ) {
$variation = wc_get_product($cart_item['variation_id']);
$variationFormattedName = $variation->get_formatted_name();
$cartItemVariationIsChildrenRace = (strpos($variationFormattedName, 'Детский')>0);
write_log($cartItemVariationIsChildrenRace);
@MasterHans
MasterHans / Add filter in Backend
Created Oct 26, 2021
Add filter in Backend to DataProvider
View Add filter in Backend
other.country.controller.js:
c.possibleCountries = {
config: {},
filter: {
countryType: 0
},
data: [],
};
@MasterHans
MasterHans / Add filter to grid through the FrontEnd
Created Oct 26, 2021
Add filter to grid through the FrontEnd
View Add filter to grid through the FrontEnd
_.set(c.possibleCountries.filter, ['filters', 'groupOp'], 'AND');
//exclude selected countries
_.set(c.possibleCountries.filter, ['filters', 'rules', 'id'], {
field: 'id',
op: 'ni',
data: c.model.countriesTypeIds
});
//set filter on EU countries
_.set(c.possibleCountries.filter, ['filters', 'rules', 'typeId'], {
field: 'typeId',
@MasterHans
MasterHans / PHP create class without constructor
Created Oct 21, 2021
PHP create class without constructor
View PHP create class without constructor
public function getSettingsFieldsMap($providerName, $moduleName)
{
Yii::import('application.modules.' . $moduleName . '.models.' . $providerName);
$reflection = new ReflectionClass($providerName);
$instance = $reflection->newInstanceWithoutConstructor();
return $instance->getAttributeConfig();
}