<?php

$ids = [];

$str_select_query = 'SELECT id from ' . $config['table_prefix'] . 'calc where expert_mode!=1';
$result = sql_query($str_select_query);
while($row = sql_fetch_assoc($result)){
    $ids[] = $row['id'];
}

if(count($ids) > 0){
    $str_update_query = 'UPDATE ' . $config['table_prefix'] . 'calc SET calculate = REPLACE(calculate, "$(this).next(\'.ui-datepicker-trigger\').trigger(\'click\');", "if(!$(this).hasClass(\'hasDatepicker\')){
        $(this).next(\'.ui-datepicker-trigger\').trigger(\'click\');
    }") WHERE id IN (' . implode($ids, ',') . ')';

    run_query($str_update_query);
}


