Exemplo n.º 1
0
function office_table_direction($data_array, $office_code, $office_name = '')
{
    global $db, $db_rs;
    $html = '<div style="display: inline-block; margin-right: 10px;">';
    if ($office_name != '') {
        $html .= '#office_title#';
    }
    // Если у нас человек имеет право смотреть технику с разбитием по ответственным, то и таблица должна ему строиться немного иная;
    // Сначала сформируем массив с руководителями направлений;
    $sql = "select `users_apps`.`user_name` from `tech_types`\n            left join `tech_inj_rules` on `tech_inj_rules`.`tech_id` = `tech_types`.`id`\n            left join `users_apps` on `users_apps`.`dep_id` = `tech_inj_rules`.`dep_id` and `users_apps`.`app_id` = `tech_inj_rules`.`app_id`\n            where `users_apps`.`app_id` = 13\n            group by `users_apps`.`user_name`";
    $tech_direction_boss = $db_rs->all($sql);
    $direction_boss = array();
    foreach ($tech_direction_boss as $tech_boss) {
        $direction_boss[$tech_boss['user_name']] = array();
    }
    // Добавляем еще одно пустого руководителя для напрвления "РАЗНОЕ";
    $direction_boss['other'] = array();
    // После формирования массива руководителей направления, нам надо наполнить эти массивы;
    foreach ($data_array as $orders) {
        // Зная tu техники, мы можем определить руководителя ее направления;
        // Получаем наименование техники:
        $order_tech_name = $orders['tu'];
        // Определяем руководителя направления данного типа техники;
        $sql = "select `users_apps`.`user_name` from `tech_types`\n                left join `tech_inj_rules` on `tech_inj_rules`.`tech_id` = `tech_types`.`id`\n                left join `users_apps` on `users_apps`.`dep_id` = `tech_inj_rules`.`dep_id` and `users_apps`.`app_id` = `tech_inj_rules`.`app_id`\n                where `users_apps`.`app_id` = 13 and `tech_types`.`tech_name` = '" . $order_tech_name . "'";
        $current_tech_boss = $db_rs->one($sql);
        if ($current_tech_boss['user_name'] == '') {
            $direction_boss['other'][] = $orders;
        } else {
            $direction_boss[$current_tech_boss][] = $orders;
        }
    }
    // Далее мы уже выводим результирующий массив;
    $html .= '<table>';
    $html .= '<tr>';
    $html .= '<td class="row_top">Номер заказа</td>';
    $html .= '<td class="row_top inf_row">Тип техники</td>';
    $html .= '<td class="row_top inf_row">Модель</td>';
    $html .= '<td class="row_top inf_row">Неисправность</td>';
    $html .= '<td class="row_top inf_row">Дата</td>';
    $html .= '</tr>';
    // Теперь мы будем обрабатывать каждый массив, по каждому руководителю направлению отдельно;
    $full_office_key = 0;
    foreach ($direction_boss as $boss_login => $boss_techs) {
        $office_key = 0;
        // Выводи имя руководителя направления котрое мы получим отдельным запросом;
        if ($boss_login != 'other') {
            $sql = "SELECT CONCAT(`fam`, ' ', `name`) as `boss_name` FROM `users` WHERE `login` = '" . $boss_login . "';";
            $boss_name = $db->one($sql);
        } else {
            // Если у этого направления нет руководителя;
            $boss_name = 'Другое';
        }
        /* СУПЕР КОСТЫЛЬ */
        if ($office_code != 'kalinina') {
            // Получаем имя главвного на офисе;
            return office_table($data_array, $office_code, $office_name);
        }
        // Метка дя замены итоговой "пашкой";
        $html .= '#boss_name#';
        // Так как у нас это массив подмассивов, нам надоо отдельно все это обработать;
        foreach ($boss_techs as $key => $order_array) {
            // Проверяем сответствие офиса;
            if ($order_array['office'] == $office_code) {
                $office_key++;
                // Визуальный класс чет нечет;
                if ($office_key % 2 != 0) {
                    $class = 'row_1';
                } else {
                    $class = 'row_2';
                }
                $numm = $order_array['numm'];
                $date = date('d.m.Y H:i:s', strtotime($order_array['date']));
                $tu = $order_array['tu'];
                $model = $order_array['model'];
                $diag = $order_array['a1'];
                $gar_rem = $order_array['gar_rem'];
                $html .= '<tr>';
                $print_numm = '<div style="display: inline-block" class="numm_info">' . $numm . '</div>';
                $html .= '<td class="' . $class . '" align="center" style="' . ($gar_rem == '1' ? 'font-weight: bold;' : '') . '">' . $print_numm . '</td>';
                $html .= '<td class="' . $class . ' inf_row">' . $tu . '</td>';
                $html .= '<td class="' . $class . ' inf_row" style="width: 4em;">' . $model . '</td>';
                $html .= '<td class="' . $class . ' inf_row" style="width: 6em;">' . $diag . '</td>';
                $html .= '<td class="' . $class . ' inf_row" align="center">' . $date . '</td>';
                $html .= '</tr>';
            }
        }
        $html .= '<tr>';
        $html .= '<td class="row_top" style="background-color: #262626" align="center" colspan="5">Всего <b>' . $office_key . '</b></td>';
        $html .= '</tr>';
        $full_office_key += $office_key;
        // Заменяем метка на нужную шапку;
        $html = str_replace('#boss_name#', '<tr><td class="row_top" style="background-color: #4d4d4d" colspan="5">' . $boss_name . ' - <b>' . $office_key . '</b></td></tr>', $html);
    }
    $html .= '</table>';
    $html .= '</div>';
    $html = str_replace('#office_title#', '<p class="office_title">' . $office_name . ' - ' . $full_office_key . '</p>', $html);
    return $html;
}
Exemplo n.º 2
0
    foreach ($apps_array as $app) {
        $apps[$app['user_name']] = $app['app_name'];
    }
    // Получаем офимсы отдельно;
    $sql = "SELECT `code`, `name` FROM `office` WHERE `kassa_list` = 1";
    $offces = $db->all($sql);
    foreach ($offces as $offces_array) {
        $office_opoozduns = array();
        foreach ($opozdun as $opozdun_array) {
            if ($opozdun_array['code'] == $offces_array['code']) {
                $office_opoozduns[] = array('fio' => $systems->get_user_avatar_and_full_name('', $opozdun_array['login']), 'app' => $apps[$opozdun_array['login']], 'date' => $opozdun_array['date']);
            } else {
                continue;
            }
        }
        $html .= office_table($office_opoozduns, $offces_array['name']);
    }
    echo $html;
    die;
}
function office_table($opozdun, $office = '')
{
    //$html = '';
    $html = '<div style="margin-right: 10px; float: inherit; display: inline-block;">';
    if ($office != '') {
        $html .= '<p class="office_title">' . $office . '</p>';
    }
    $html .= '<table>';
    $html .= '<tr>';
    $html .= '<td class="row_top">ФИО</td>';
    $html .= '<td class="row_top inf_row">Должность</td>';
Exemplo n.º 3
0
$excel = '';
if ($_SESSION['department_id'] == '2' || $_SESSION['department_id'] == 12) {
    // Получаем сначала список всех офисов, так как директор должен видетьт все офисы;
    $sql = "SELECT `code`, `name` FROM `office` WHERE `kassa_list` = 1";
    $offices = $db->all($sql);
    foreach ($offices as $office) {
        $sql = "SELECT `remont`.`numm`, `remont`.`tu`, `remont`.`torg`, `remont`.`model`, `remont`.`ser_no`, `status`.`name` , `remont`.`office`\n        FROM `remont`\n        left join `status` on `status`.`code` = `remont`.`status`\n        WHERE `remont`.`office` = '" . $office['code'] . "' and `remont`.`status` not in ('16', '12')\n        ORDER BY `remont`.`numm` ASC LIMIT 3000;";
        $offices_items = $db->all($sql);
        if (count($offices_items) != 0) {
            $html .= office_table($offices_items, $office['name']);
            $excel .= iconv("utf-8", "windows-1251", office_table_excel($db->all($sql), $office['name']));
        }
    }
} else {
    $sql = "SELECT `remont`.`numm`, `remont`.`tu`, `remont`.`torg`, `remont`.`model`, `remont`.`ser_no`, `status`.`name` , `remont`.`office`\n        FROM `remont`\n        left join `status` on `status`.`code` = `remont`.`status`\n        WHERE `remont`.`office` = '" . $_SESSION['office'] . "' and `remont`.`status` not in ('16', '12')\n        ORDER BY `remont`.`numm` ASC LIMIT 3000;";
    $html .= office_table($db->all($sql));
    $excel .= iconv("utf-8", "windows-1251", office_table_excel($db->all($sql)));
}
$html = $systems->excel_export($html, 'invent_excel_export') . $html;
echo $html;
function office_table($items_array, $office_name = '')
{
    $html = '';
    if ($office_name != '') {
        $html .= '<p class="office_title">' . $office_name . '</p>';
    }
    $html .= '<table width="100%">';
    $html .= '<tr>';
    $html .= '<td class="row_top">Номер заказа</td>';
    $html .= '<td class="row_top inf_row">Тип техники</td>';
    $html .= '<td class="row_top inf_row">Производитель</td>';
Exemplo n.º 4
0
                }
            }
        }
        // Вывоим резльтат работы;
        //$office_orders = array_unique($office_orders);
        $html .= office_table($office_orders, $all_office_array['name']);
        $all_priem_count += count($office_orders);
    }
    // А тут мы должны показать приемку по всекм офисам;
} else {
    // Показываем пприемку только этого офиса;
    $sql = "select `numm`, `saved` from `remont` where `status` in (18, 22, 29) and " . ($_SESSION['office'] == 'kalinina' ? "`office` = '" . $_SESSION['office'] . "' AND `office2` = '" . $_SESSION['office'] . "'" : "`office` = '" . $_SESSION['office'] . "'") . ' order by `saved` asc';
    //$sql = "select `numm`, `saved` from `remont` where `status` in (18, 22) and `office` = '".$_SESSION['office']."' order by `saved` asc";
    write_log($sql, 'otk_query');
    $all_orders = $db->all($sql);
    $html .= office_table($all_orders);
}
if ($all_priem_count != '') {
    echo '<p class="itog_title">Всего ' . $all_priem_count . '</p>';
}
echo $html;
function office_table($all_orders, $office = '')
{
    global $time_1, $time_2, $systems, $db_rs;
    $html = '';
    $time_1_array = array();
    $time_2_array = array();
    $time_3_array = array();
    foreach ($all_orders as $all_orders_array) {
        $numm = $all_orders_array['numm'];
        $order_numm = '<div style="display: inline-block" class="numm_info">' . $numm . '</div>';