Ejemplo n.º 1
0
 function __construct($par = null, $unset_ID = false)
 {
     if ($par && is_merged($par)) {
         set_ref_merge($this, $par);
         if ($unset_ID) {
             unset($this->ID);
         }
     }
 }
Ejemplo n.º 2
0
function update_detblock($ID, $par)
{
    global $DETDB;
    if (is_merged($par) && is_numeric($ID) && ($obj = $DETDB->isset_cell('detblocks_types', $ID))) {
        $par = (array) $par;
        $custom = array();
        if (isset($par['code']) && $par['code']) {
            $par['code'] = canone_code($par['code']);
            if (!validate_code($par['code'])) {
                return false;
            } else {
                $custom['code'] = $par['code'];
            }
        }
        if (isset($par['name'])) {
            $custom['name'] = $par['name'];
        }
        if (isset($par['description'])) {
            $custom['description'] = $par['description'];
        }
        return $DETDB->update('detblocks_types', $custom, "WHERE ID={$ID}");
    }
    return false;
}
Ejemplo n.º 3
0
 function __construct($array)
 {
     if (is_merged($array)) {
         set_ref_merge($this, $array);
     }
 }
Ejemplo n.º 4
0
function show_calendar_events($params = array())
{
    global $DETDB;
    $custom = array('links' => false, 'type' => 'month', 'month' => isset($_GET['month']) && is_numeric($_GET['month']) ? $_GET['month'] : date('m'), 'year' => isset($_GET['year']) && is_numeric($_GET['year']) ? $_GET['year'] : date('Y'), 'start' => '', 'end' => '', 'show' => 'table', 'exclude_ID' => null, 'limit' => 100);
    $query = null;
    if (is_merged($params)) {
        $custom = set_merge($custom, $params);
        if ($custom['start']) {
            $custom['start'] = date('Y-m-d H:i', strtotime($custom['start']));
        }
        if ($custom['end']) {
            $custom['end'] = date('Y-m-d H:i', strtotime($custom['end']));
        }
        $custom['year'] = is_numeric($custom['year']) && checkdate('01', '01', $custom['year']) ? $custom['year'] : date('Y');
        $custom['month'] = is_numeric($custom['month']) && checkdate($custom['month'], '01', $custom['year']) ? $custom['month'] : date('m');
        if ($custom['type'] == 'month') {
            $query = array(array('param' => 'MONTH(date_start)', 'value' => $custom['month']), array('param' => 'YEAR(date_start)', 'value' => $custom['year']));
        } else {
            $query = array(array('param' => 'date_end', 'value' => $custom['start'], 'relation' => '>='), array('param' => 'date_start', 'value' => $custom['end'], 'relation' => '<='));
        }
        if ($custom['exclude_ID'] && !is_array($custom['exclude_ID'])) {
            $custom['exclude_ID'] = array($custom['exclude_ID']);
        }
        if ($custom['exclude_ID']) {
            foreach ($custom['exclude_ID'] as $item) {
                $query[] = array('param' => 'ID', 'value' => $item, 'relation' => '!=');
            }
        }
    }
    $events = $query ? $DETDB->select(array('table' => 'calendar_events', 'cols' => '*', 'cond' => $query, 'order_by' => 'date_start', 'order_type' => 'ASC', 'limit' => $custom['limit'])) : null;
    ?>
        <?php 
    if ($events && count($events) > 0 && $custom['show'] == 'table') {
        ?>
            <table class="table table-striped table-hover table-bordered" width="100%">
                <thead>
                    <tr>
                        <th width="7%">Дата</th>
                        <th width="7%">Время</th>
                        <th>Наименование  мероприятия</th>
                        <th width="18%">Место проведения</th>
                        <th width="14%">Ответственный</th>
                    </tr>
                </thead>
                <tbody>
                    <?php 
        foreach ($events as $item) {
            ?>
                        <?php 
            $start = strtotime($item->date_start);
            $end = strtotime($item->date_end);
            ?>
                        <tr class="field">
                            <td>
                                <?php 
            echo date('d', $start);
            if ($end && $end > 0 && date('d', $start) != date('d', $end)) {
                echo ' - ' . date('d', $end);
            }
            ?>
                            </td>
                            <td>
                                <?php 
            if ($item->date_params && check_json($item->date_params)) {
                $item->date_params = json_decode($item->date_params, true);
                if (count($item->date_params) == 2) {
                    $item->date_params = !$item->date_params[0];
                }
            } else {
                $item->date_params = true;
            }
            if ($start && $item->date_params) {
                echo date('G.i', $start);
                if ($end && $end > 0 && $start && $end != $start) {
                    echo ' - ' . date('G.i', $end);
                }
            }
            ?>
                            </td>
                            <td><?php 
            echo $item->name;
            ?>
                            <?php 
            if ($custom['links']) {
                ?>
                                <p class="controls">
                                    <a href="<?php 
                echo get_page_link('calendar_event_add') . '&event_id=' . $item->ID;
                ?>
">Редактировать</a> |
                                    <a class="table-delete button-control" data-set-action="delete_calendar_event" data-id="<?php 
                echo $item->ID;
                ?>
">Удалить</a>
                                </p>
                            <?php 
            }
            ?>
                            </td>
                            <td><?php 
            echo $item->place;
            ?>
</td>
                            <td><?php 
            echo $item->worker;
            ?>
</td>
                        </tr>
                    <?php 
        }
        ?>
                </tbody>
                <tfoot>
                    <tr>
                        <th>Дата</th>
                        <th>Время</th>
                        <th>Наименование  мероприятия</th>
                        <th>Место проведения</th>
                        <th>Ответственный</th>
                    </tr>
                </tfoot>
            </table>
        <?php 
    } elseif ($custom['show'] == 'json') {
        ?>
            <?php 
        echo json_val_encode($events);
        ?>
        <?php 
    } else {
        ?>
            <p>Нет событий, выбранных за данный период.</p>
        <?php 
    }
    ?>
    <?php 
}
Ejemplo n.º 5
0
function update_users_groups($par, $cond)
{
    global $DETDB;
    if (is_merged($par)) {
        $par = (array) $par;
        if (isset($par['code'])) {
            $par['code'] = canone_code($par['code']);
            if (!validate_code($par['code'])) {
                return false;
            }
        }
        return $DETDB->update('users_groups', $par, $cond);
    }
    return false;
}
Ejemplo n.º 6
0
function update_remote_key($ID, $key)
{
    global $DETDB;
    if (is_object($key)) {
        $key = (array) $key;
    }
    if (is_merged($key) && isset($key['key_value'])) {
        $L = strlen($key['key_value']);
        $custom = set_merge(array('name' => '', 'key_value' => '', 'rules' => ''), $key);
        if ($L >= 16 && $L <= 20) {
            if (preg_match('/^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPRQSTUVWXYZ0123456789!@#$%^*()]{16,20}$/i', $custom['key_value'])) {
                if ($DETDB->update('remote_keys', $custom, "WHERE ID={$ID}")) {
                    return true;
                } else {
                    push_output_message(array('title' => 'Ошибка!', 'text' => 'Произошла неизвестная ошибка, возможно, ключ повторяется', 'class' => 'alert alert-danger'));
                }
            } else {
                push_output_message(array('title' => 'Ошибка ключа!', 'text' => 'Воспользуйтесь генератором ключей', 'class' => 'alert alert-danger'));
            }
        } else {
            push_output_message(array('title' => 'Ошибка!', 'text' => 'Ключ должен иметь длину от 16 до 20 символов', 'class' => 'alert alert-danger'));
        }
    }
    return false;
}
Ejemplo n.º 7
0
function ajax_make_res($param = 'success', $body = '', $title = '', $data = '', $error = false)
{
    $custom = array('status' => '', 'body' => $body, 'title' => $title, 'data' => $data, 'error' => $error);
    if (is_merged($param)) {
        $custom = set_merge($custom, $param);
    } else {
        $custom['status'] = $param;
    }
    if ($custom['error']) {
        $custom['body'] .= get_output_result_messages('error', true);
    }
    unset($custom['error']);
    return json_val_encode($custom);
}