function fbLoadPalk($idPage) { //Проверяем достаточен ли уровень доступа //verifity("buch"); $access = new ToBase(); $level = $access->accessYes($idPage); if ($level != 0) { $dt['login'] = $level; } if ($level == 0) { $dt['login'] = false; echo json_encode($dt); exit; } //print_r($_REQUEST); $data = json_decode($_REQUEST["data"]); //print_r($data); /* алгоротм: получить список w_id по указанной профессии в цикле просчитать каждую фамилию массив с данными клиенту */ $w_id = 0; //if(!empty($data->w_id)){ $w_id = (int) $data->w_id; //работник //} $wa_id = (int) $data->wa_id; //должность $month = (int) $data->month; $year = (int) $data->year; if (0 == $w_id) { //echo "w_id=".$w_id; выбраны все пользователи $query = "SELECT `w_id` FROM `ns_workers` WHERE `wa_id`='{$wa_id}'"; $result = $access->resQuery($query); //$result=mysql_query($query)or die("Запрос не выполнен ".mysql_error()); if (@mysql_num_rows($result) == 0) { //нет результатов выборки $dt["f"] = 0; echo json_encode($dt); exit; } //Есть результаты выборки $i = 0; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $id_workers[$i] = $row["w_id"]; //массив работников $i++; } $kokku = 0; //print_r($id_workers); foreach ($id_workers as $num => $w_id) { // $query="SELECT ns_results.countDid, ns_workers.family, ns_workers.name, ns_workers.payment, ns_techmap.time // FROM ns_results, ns_workers, ns_admin, ns_models, ns_techmap // WHERE // ns_results.year='$year' AND // ns_workers.w_id='$w_id' AND // ns_workers.w_id=ns_results.w_id AND // ns_results.a_id=ns_admin.a_id AND // ns_results.month='$month' AND // ns_results.m_id=ns_models.m_id AND // ns_results.t_id=ns_techmap.t_id"; $query = "SELECT `family`,`name`,`w_id_payment`,`operate_time`,`countDid` FROM `ns_results` WHERE `w_id`='{$w_id}' AND `year`='{$year}' AND `month`='{$month}'"; $result = $access->resQuery($query); if ($result == false) { //запрос пуст $dt["status"] = 0; echo json_encode($dt); exit; } else { // запрос не пуст $dt["status"] = 1; $sumPayment = 0; //сумма заработка пользователя $sumTime = 0; //время работы пользователя while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $dt["data"][$num]["family"] = $row["family"]; $dt["data"][$num]["name"] = $row["name"]; $sumPayment += $row["countDid"] * $row["w_id_payment"] * $row['operate_time']; $sumTime += $row["operate_time"] * $row["countDid"]; } if ($sumPayment != 0 || $sumTime != 0) { $dt["data"][$num]["sumPrice"] = round($sumPayment, 2); $dt["data"][$num]["sumTime"] = round($sumTime, 2); //$sumTime; $kokku += round($sumPayment, 2); } } } $dt["kokku"] = round($kokku, 2); $dt["f"] = 0; echo json_encode($dt); } else { // echo "w_id=".$w_id; выбран 1 пользователь // $query="SELECT ns_results.countDid, ns_workers.family, ns_workers.name, ns_workers.payment, ns_techmap.time // FROM ns_results, ns_workers, ns_admin, ns_models, ns_techmap // WHERE // ns_workers.w_id='$w_id' AND // ns_results.month='$month' AND // ns_results.year='$year' AND // ns_workers.w_id=ns_results.w_id AND // ns_results.a_id=ns_admin.a_id AND // ns_results.m_id=ns_models.m_id AND // ns_results.t_id=ns_techmap.t_id"; $query = "SELECT `family`,`name`,`w_id_payment`,`operate_time`,`countDid` FROM `ns_results` WHERE `w_id`='{$w_id}' AND `year`='{$year}' AND `month`='{$month}'"; $result = $access->resQuery($query); $sumPayment = 0; $sumTime = 0; if ($result == false) { $dt["status"] = 0; echo json_encode($dt); exit; } else { $dt["status"] = 1; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { //print_r ($row); $dt["family"] = $row["family"]; $dt["name"] = $row["name"]; $sumPayment += $row["countDid"] * $row["w_id_payment"] * $row['operate_time']; $sumTime += $row["operate_time"] * $row["countDid"]; } if ($sumPayment != 0 || $sumTime != 0) { $dt["sumPrice"] = round($sumPayment, 2); $dt["sumTime"] = round($sumTime, 2); //$sumTime; } else { $dt["family"] = "Нет данных"; $dt["name"] = " "; $dt["sumPrice"] = "Нет данных"; $dt["sumTime"] = "Нет данных"; $dt["kokku"] = "0"; } $dt["f"] = 1; echo json_encode($dt); } } }
<?php print_r($_REQUEST); //echo mb_convert_case('это строка', MB_CASE_TITLE, "UTF-8"); function autoload($className) { set_include_path('Classes/'); spl_autoload($className); //replaces include/require } spl_autoload_extensions('.php'); spl_autoload_register('autoload'); include_once 'Classes/ToBase.php'; $base = new ToBase(); if (!$base->accessYes('L4')) { $data["login"] = false; exit; } include_once 'Classes/Techmap.php'; include_once 'Classes/ModelsList.php'; include_once 'Classes/SectionsList.php'; $tm = new Techmap($base->getConnDB()); //echo "<br>Загружаем файл"; if (!function_exists('mb_ucfirst')) { function mb_ucfirst($str, $enc = 'utf-8') { return mb_strtoupper(mb_substr($str, 0, 1, $enc), $enc) . mb_substr($str, 1, mb_strlen($str, $enc), $enc); } } //echo "<br>Загружаем файл"; function sumNotes($value) {