public function setRecord($data) { $data[blocktype] = $this->blocktype; $operation[$data[operation_id]] = array('date' => $data[action_date], 'comment_id' => sqltable_model::getCommentId($data[comment])); // если в поле для нового ввели номер сопроводиловки уже существующий в журнале // то будем править его $sql = "SELECT * FROM {$this->maintable} WHERE lanch_id='{$data[lanch_id]}'"; $res = sql::fetchOne($sql); if (empty($res)) { // гадство! тут нужен уникальный, а без коментариев будет получаться один sql::insert('coments', array(array("comment" => multibyte::Json_encode($operation)))); $data[coment_id] = sql::lastId(); } else { $coment = multibyte::Json_decode(sqltable_model::getComment($res[coment_id])); $coment[$data[operation_id]] = $operation[$data[operation_id]]; // заменить старый по ключу sql::insertUpdate('coments', array(array("id" => $res[coment_id], "comment" => multibyte::Json_encode($coment)))); $data[edit] = $res[id]; // если был такой его и правим $data[coment_id] = $res[coment_id]; } $data[lastoperation] = $data[operation_id]; parent::setRecord($data); return true; }
/** * Получет две даты и выдает данные за период */ public function getRangePeriod($sdate, $edate) { $ret = array(); //console::getInstance()->out("$sdate nnn $edate"); $sdate = date("Y-m-d", mktime(0, 0, 0, substr($sdate, 3, 2), substr($sdate, 0, 2), substr($sdate, 6, 4))); //$dyear."-".$dmonth."-".$dday; $edate = date("Y-m-d", mktime(0, 0, 0, substr($edate, 3, 2), substr($edate, 0, 2), substr($edate, 6, 4))); //$dyear."-".$dmonth."-".$dday; // выбор всех непустых названий $sql = "SELECT *,sk_{$this->sklad}_spr.id FROM {$this->db}sk_{$this->sklad}_spr\n\t\t\t\tJOIN {$this->db}sk_{$this->sklad}_ost ON sk_{$this->sklad}_ost.spr_id=sk_{$this->sklad}_spr.id\n\t\t\t\tWHERE nazv<>''\n\t\t\t\tORDER BY nazv"; $res = sql::fetchAll($sql); foreach ($res as $rs) { // Запрос тот же что и для прихода, но берем последний и смотрим только последний и его цену $sql = "SELECT price as newprice FROM ({$this->db}sk_{$this->sklad}_dvizh)\n\t\t\t\t\tJOIN {$this->db}sk_{$this->sklad}_spr ON (sk_{$this->sklad}_spr.id=sk_{$this->sklad}_dvizh.spr_id)\n\t\t\t\t\tWHERE ddate >= '{$sdate}'\n\t\t\t\t\t\t\tAND ddate <= '{$edate}'\n\t\t\t\t\t\t\tAND sk_{$this->sklad}_spr.id='{$rs[id]}'\n\t\t\t\t\t\t\tAND type='1'\n\t\t\t\t\t\t\tAND numd<>'9999'\n\t\t\t\t\tORDER BY ddate DESC LIMIT 1"; //echo $sql; $res1 = sql::fetchOne($sql); $newprice = $res1["newprice"]; // почти такой же запрос, толь до первой даты даст старую цену $sql = "SELECT price as oldprice FROM ({$this->db}sk_{$this->sklad}_dvizh)\n\t\t\t\t\tJOIN {$this->db}sk_{$this->sklad}_spr ON (sk_{$this->sklad}_spr.id=sk_{$this->sklad}_dvizh.spr_id)\n\t\t\t\t\tWHERE ddate < '{$sdate}'\n\t\t\t\t\t\t\tAND sk_{$this->sklad}_spr.id='{$rs[id]}'\n\t\t\t\t\t\t\tAND type='1'\n\t\t\t\t\t\t\tAND numd<>'9999'\n\t\t\t\t\tORDER BY ddate DESC LIMIT 1"; //echo $sql; $res1 = sql::fetchOne($sql); $oldprice = $res1["oldprice"]; // если цены отичаются добавим в вывод if ($newprice != $oldprice && $oldprice != 0 && $newprice != 0) { // проверка на ноль, чтобы не делить на него при вычислении соотношения $col[nazv] = $rs[nazv]; $col[newprice] = sprintf("%10.2f", $newprice); $col[oldprice] = sprintf("%10.2f", $oldprice); $col[ratio] = sprintf("%+10.2f", ($newprice - $oldprice) * 100 / $oldprice); $ret[] = $col; } } return $ret; }
public function getNeedArc() { return false; //чтото глючит или ктото. архивнули движения $sql = "SELECT YEAR(NOW())>(YEAR(sk_{$this->sklad}_dvizh_arc.ddate)+1) AS need\n FROM {$this->db}sk_{$this->sklad}_dvizh_arc\n ORDER BY ddate DESC LIMIT 1"; $rs = sql::fetchOne($sql); return $rs[need]; }
public function getRecord($edit) { extract($edit); foreach ($id as $key => $value) { $sql = "SELECT *,sk_{$this->sklad}_spr.id\n FROM {$this->db}sk_{$this->sklad}_dvizh\n JOIN {$this->db}sk_{$this->sklad}_spr\n ON sk_{$this->sklad}_dvizh.spr_id=sk_{$this->sklad}_spr.id\n WHERE ddate='{$ddate}' AND {$this->db}sk_{$this->sklad}_spr.id='{$value}'"; $ret[] = sql::fetchOne($sql); } return $ret; }
public function getRecord($edit) { if (empty($edit)) { $rec[customers] = $this->getCustomers(); return $rec; } $sql = "SELECT * FROM orders WHERE id='{$edit}'"; $rec = sql::fetchOne($sql); $rec[files] = $this->getFilesForId('orders', $edit); return $rec; }
public function getRights($userid) { $sql = "SELECT * FROM rtypes"; $res = sql::fetchAll($sql); $sql = "SELECT * FROM rrtypes"; $res1 = sql::fetchAll($sql); $out = array(); foreach ($res as $rs) { $rec[type] = $rs[type]; $rec[name] = "r|{$rs["id"]}"; foreach ($res1 as $rs1) { $sql = "SELECT * FROM rights WHERE type_id='{$rs["id"]}' AND u_id='{$userid}' AND rtype_id='{$rs1["id"]}'"; $rs2 = sql::fetchOne($sql); $value[$rs1["id"]] = $rs2["right"] == 1 ? 1 : 0; $values[$rs1["id"]] = $rs1["rtype"]; } $rec[value] = $value; $rec[values] = $values; $out[types][] = $rec; } return $out; }
public function getRangePeriod($sdate, $edate) { $ret = array(); console::getInstance()->out("{$sdate} nnn {$edate}"); $sdate = date("Y-m-d", mktime(0, 0, 0, substr($sdate, 3, 2), substr($sdate, 0, 2), substr($sdate, 6, 4))); //$dyear."-".$dmonth."-".$dday; $edate = date("Y-m-d", mktime(0, 0, 0, substr($edate, 3, 2), substr($edate, 0, 2), substr($edate, 6, 4))); //$dyear."-".$dmonth."-".$dday; $sql = "SELECT *,sk_{$this->sklad}_spr.id FROM {$this->db}sk_{$this->sklad}_spr\n\t\t\t\tJOIN {$this->db}sk_{$this->sklad}_ost ON sk_{$this->sklad}_ost.spr_id=sk_{$this->sklad}_spr.id\n\t\t\t\tWHERE nazv<>''\n\t\t\t\tORDER BY nazv"; $res = sql::fetchAll($sql); foreach ($res as $rs) { $prih = 0; $rash = 0; $sql = "SELECT SUM(quant) as prihod FROM ({$this->db}sk_{$this->sklad}_dvizh)\n\t\t\t\t\tJOIN {$this->db}sk_{$this->sklad}_spr ON (sk_{$this->sklad}_spr.id=sk_{$this->sklad}_dvizh.spr_id)\n\t\t\t\t\tWHERE ddate >= '{$sdate}'\n\t\t\t\t\t\t\tAND ddate <= '{$edate}'\n\t\t\t\t\t\t\tAND sk_{$this->sklad}_spr.id='{$rs[id]}'\n\t\t\t\t\t\t\tAND type='1'\n\t\t\t\t\t\t\tAND numd<>'9999'\n\t\t\t\t\tGROUP BY sk_{$this->sklad}_spr.id"; //echo $sql; $res1 = sql::fetchAll($sql); foreach ($res1 as $rs1) { $prih += $rs1["prihod"]; } $sql = "SELECT SUM(quant) as prihod FROM ({$this->db}sk_{$this->sklad}_dvizh_arc)\n\t\t\t\t\tJOIN {$this->db}sk_{$this->sklad}_spr ON (sk_{$this->sklad}_spr.id=sk_{$this->sklad}_dvizh_arc.spr_id)\n\t\t\t\t\tWHERE ddate >= '{$sdate}'\n\t\t\t\t\t\t\tAND ddate <= '{$edate}'\n\t\t\t\t\t\t\tAND sk_{$this->sklad}_spr.id='{$rs[id]}'\n\t\t\t\t\t\t\tAND type='1'\n\t\t\t\t\t\t\tAND numd<>'9999'\n\t\t\t\t\t\t\tGROUP BY sk_{$this->sklad}_spr.id"; $res1 = sql::fetchAll($sql); foreach ($res1 as $rs1) { $prih += $rs1["prihod"]; } $sql = "SELECT SUM(quant) as prihod FROM ({$this->db}sk_{$this->sklad}_dvizh)\n\t\t\t\t\tJOIN {$this->db}sk_{$this->sklad}_spr ON (sk_{$this->sklad}_spr.id=sk_{$this->sklad}_dvizh.spr_id)\n\t\t\t\t\tWHERE ddate >= '{$sdate}'\n\t\t\t\t\t\t\tAND ddate <= '{$edate}'\n\t\t\t\t\t\t\tAND sk_{$this->sklad}_spr.id='{$rs[id]}'\n\t\t\t\t\t\t\tAND type='0'\n\t\t\t\t\t\t\tAND numd<>'9999'\n\t\t\t\t\tGROUP BY sk_{$this->sklad}_spr.id"; $rs1 = sql::fetchOne($sql); if (!empty($rs1)) { $rash += $rs1["prihod"]; } $sql = "SELECT SUM(quant) as prihod FROM ({$this->db}sk_{$this->sklad}_dvizh_arc)\n\t\t\t\t\tJOIN {$this->db}sk_{$this->sklad}_spr ON (sk_{$this->sklad}_spr.id=sk_{$this->sklad}_dvizh_arc.spr_id)\n\t\t\t\t\tWHERE ddate >= '{$sdate}'\n\t\t\t\t\t\t\tAND ddate <= '{$edate}'\n\t\t\t\t\t\t\tAND sk_{$this->sklad}_spr.id='{$rs[id]}'\n\t\t\t\t\t\t\tAND type='0'\n\t\t\t\t\t\t\tAND numd<>'9999'\n\t\t\t\t\tGROUP BY sk_{$this->sklad}_spr.id"; $res1 = sql::fetchAll($sql); foreach ($res1 as $rs1) { $rash += $rs1["prihod"]; } if ($prih != 0 || $rash != 0 || $rs["ost"] != 0) { $cols[nazv] = $rs[nazv]; $cols[prihod] = sprintf("%10.2f", $prih); $cols[rashod] = sprintf("%10.2f", $rash); $cols[ost] = sprintf("%10.2f", $rs["ost"]); $cols[edizm] = $rs[edizm]; $ret[] = $cols; } } return $ret; }
public function getPath($id) { $sql = "SELECT customer,blockname\r\n FROM lanch JOIN (blocks,customers)\r\n ON (blocks.id=lanch.block_id\r\n AND customers.id=blocks.customer_id )\r\n WHERE lanch.id='{$id}'"; $rs = sql::fetchOne($sql); return "z:\\Заказчики\\{$rs['customer']}\\{$rs['blockname']}"; }
/** * Возвращает идентификатор коментария по тексту коментария * @param string $comment * @return int */ public static function getCommentId($comment) { $sql = "SELECT * FROM coments WHERE comment='{$comment}'"; $rs = sql::fetchOne($sql); if (empty($rs)) { $sql = "INSERT INTO coments (comment) VALUES ('{$comment}')"; sql::query($sql); return sql::lastId(); } else { return $rs[id]; } }
/** * Сохраняет или обновляет данные о расчете цены в таблице orderformoney * @param array $rec * @return var */ public function moneyfororder($rec) { $rec = multibyte::cp1251_to_utf8($rec); extract($rec); $rec[hash] = hash('md5', $customer . $order . $board . $mater . $trud); $sql = "SELECT * FROM moneyfororder WHERE hash='{$rec[hash]}'"; $rs = sql::fetchOne($sql); if (!empty($rs)) { $rec[id] = $rs[id]; } //echo $sql; sql::insertUpdate("moneyfororder", array($rec)); return true; }
public function getRecord($id) { $sql = "SELECT * FROM todo WHERE id='{$id}'"; $rec = sql::fetchOne($sql); return $rec; }
public function getDataForCalc($id) { $rec = array(); $sql = "SELECT *,CONCAT (number,' от ',DATE_FORMAT(orderdate,'%d.%m.%Y')) as letter, " . "boards.sizex/100.0 as psizex, " . "boards.sizey/100.0 as psizey, " . "blocks.sizex/100.0 as bsizex, " . "blocks.sizey/100.0 as bsizey, " . "immer*auarea as gold, " . "CONCAT(numlam,' ',lsizex,'x',lsizey) as lamel, " . "blocks.comment_id as bcid " . "FROM posintz JOIN (tz,orders,customers,blocks,blockpos,boards) " . "ON (posintz.tz_id=tz.id " . "AND tz.order_id=orders.id " . "AND posintz.block_id=blocks.id " . "AND orders.customer_id=customers.id " . "AND blockpos.block_id=blocks.id " . "AND blockpos.board_id=boards.id ) " . "WHERE posintz.id='{$id}'"; $rec = sql::fetchOne($sql); $params = json_decode(multibyte::Unescape(sqltable_model::getComment($rec["bcid"])), true); //получим текщий комент из блока $rec[eltest] = $params[eltest]; $rec[etpib] = $params[etpib]; $rec[etpoints] = $params[etpoints]; $rec[etcompl] = $params[etcompl]; $rec[thickness] = (double) $rec[thickness]; $rec[type] = $rec[layers] > 2 ? 'mpp' : 'dpp'; $rec[template] = "r{$rec[type]}.xls"; preg_match('/(?P<nummask>[+0-9]*)(?P<mask>.*)/i', $rec[mask], $matches); $rec[mask] = $matches[mask]; $rec[nummask] = empty($matches[nummask]) ? 2 : $matches[nummask]; $rec[frez_factor] = $rec[frez_factor] > 0 ? $rec[frez_factor] : 1.0; $orderstring = fileserver::removeOSsimbols($rec[letter] . " tz{$rec[tz_id]} posintz{$id}"); $rec[filename] = "t:\\\\Расчет стоимости плат\\\\{$rec[customer]}\\\\{$rec[blockname]}\\\\{$orderstring}.xls"; return $rec; }
public function getUserById($id) { $sql = "SELECT * FROM users WHERE id='{$id}'"; $user = sql::fetchOne($sql); return $user; }
require $_SERVER["DOCUMENT_ROOT"] . "/lib/engine.php"; authorize(); // вызов авторизации $processing_type = basename(__FILE__, ".php"); ob_start(); if (isset($edit)) { if (!empty($id)) { $sql = "SELECT * FROM customers WHERE id='{$id}'"; $rs = sql::fetchOne($sql); $_SESSION[customer_id] = $rs[id]; $_SESSION[customer] = $rs[customer]; echo "ok<script>selectmenu('orders','');</script>"; exit; } else { $sql = "SELECT * FROM customers WHERE id='{$edit}'"; $cust = sql::fetchOne($sql); $form = new Edit($processing_type); $form->init(); $form->addFields(array(array("type" => CMSFORM_TYPE_TEXT, "name" => "customer", "label" => "Краткое название (имя каталога):", "value" => $cust["customer"]), array("type" => CMSFORM_TYPE_TEXT, "name" => "fullname", "label" => "Полное название (для теззаданий):", "value" => $cust["fullname"], "options" => array("html" => "size=60")), array("type" => CMSFORM_TYPE_TEXT, "name" => "kdir", "label" => "Каталог на диске К (для сверловок):", "value" => $cust["kdir"]))); $form->show(); } } elseif (isset($delete)) { // удаление $sql = "DELETE FROM customers WHERE id='{$delete}'"; sql::query($sql); sql::error(true); // удаление связей // удалить и платы заказчика $sql = "SELECT * FROM plates WHERE customer_id='{$delete}'"; $res = sql::fetchAll($sql); foreach ($res as $rs) {
public function getRecord($id) { $sql = "SELECT *, customers.id AS cusid, boards.id AS board_id\n FROM zadel\n JOIN (customers,boards)\n ON (zadel.board_id=boards.id AND boards.customer_id=customers.id)\n WHERE zadel.id='{$id}'"; $rec = sql::fetchOne($sql); return $rec; }
/** * Универсальный запрос и возврат * @param array $rec содержит массив REQUEST с параметрами * должны быть $id, $table, $format, соответственно идентификатор в таблице, таблица и формат возврата * Так как используется для запросов из скриптов (САМ, cmd, bash) форматы * line - посторочно без ключа * keyline - посторочно ключ|значение (default) * array - в массиве PHP на всякий случай * json - ну понятно * @return variable в зависимости * rem tear "http://baza4/?level=getdata&getdata[act]=uniget&table=customers&id=5" > res * rem tear "http://baza4/?level=getdata&getdata[act]=uniget&object=orders_customers_model&id=5" > res * rem tear "http://baza4/?level=getdata&getdata[act]=uniget&object=orders_customers_model&id=5&format=json" > res * rem tear "http://baza4/?level=getdata&getdata[act]=uniget&table=customers&id=%%D0%%90%%D0%%B7%%D0%%B8%%D0%%BC%%D1%%83%%D1%%82&field=customer" >res * tear "http://baza4/?level=getdata&getdata[act]=uniget&table=customers&id=Аврора&field=customer" >res */ public function uniget($rec) { if (!multibyte::is_utf($rec)) { $rec = multibyte::cp1251_to_utf8($rec); } extract($rec); if (!isset($format)) { $format = "keyline"; } if (isset($id)) { if (isset($table)) { if (1 * $id != 0) { $sql = "SELECT * FROM `{$table}` WHERE id='{$id}'"; } else { if (isset($field)) { $sql = "SELECT * FROM `{$table}` WHERE `{$field}`='{$id}'"; } else { // не определить return; } } $res = sql::fetchOne($sql); } elseif (isset($object)) { if (class_exists($object)) { $object = new $object(); if (method_exists($object, "getRecord")) { $res = $object->getRecord($id); } } } // вывод if ($format == "json") { $res = json_encode($res, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP); echo $res; return $res; } elseif ($format == "array") { return $res; } else { foreach ($res as $key => $value) { if ($format == "line") { echo "{$value}\n"; } else { echo "{$key}|{$value}\n"; } } return; } } }
$edit = $_GET["edit"]; $id = $_GET["id"]; $delete = $_GET["delete"]; if (isset($edit)) { if (!empty($id)) { $sql = "SELECT *,orders.id as order_id FROM orders JOIN customers ON customers.id=customer_id WHERE orders.id='{$id}'"; $rs = sql::fetchOne($sql); $_SESSION[order_id] = $rs[order_id]; $_SESSION[order] = $rs[number]; $_SESSION[orderdate] = $rs[orderdate]; $_SESSION[customer_id] = $rs[customer_id]; $_SESSION[customer] = $rs[customer]; echo "ok<script>selectmenu('tz','');</script>"; } else { $sql = "SELECT * FROM orders WHERE id='{$edit}'"; $ord = sql::fetchOne($sql); $form = new Edit($processing_type); $form->init(); if (empty($edit) && empty($_SESSION[customer_id])) { $customers = array(); $sql = "SELECT id,customer FROM customers ORDER BY customer"; $res = sql::fetchAll($sql); foreach ($res as $rs) { $customers[$rs[id]] = $rs[customer]; } $form->addFields(array(array("type" => CMSFORM_TYPE_SELECT, "name" => "customerid", "label" => "Заказчик:", "values" => $customers))); } else { $form->addFields(array(array("type" => CMSFORM_TYPE_HIDDEN, "name" => "customerid", "value" => !empty($_SESSION[customer_id]) ? $_SESSION[customer_id] : $ord["customer_id"], "options" => array("html" => "size=30")))); } $form->addFields(array(array("type" => CMSFORM_TYPE_TEXT, "name" => "orderdate", "label" => 'Дата:', "value" => date2datepicker($ord[orderdate]), "options" => array("html" => ' datepicker=1 '), "check" => array("type" => CMSFORM_CHECK_NUMERIC), "format" => array("type" => CMSFORM_FORMAT_CUSTOM, "pregPattern" => "/[0-9][0-9]\\.[0-9][0-9]\\.[0-9][0-9][0-9][0-9]/"), "obligatory" => true), array("type" => CMSFORM_TYPE_TEXT, "name" => "number", "label" => "Номер письма:", "value" => $ord["number"], "options" => array("html" => "size=30"), "obligatory" => true), array("type" => CMSFORM_TYPE_FILE, "name" => "order_file", "label" => "Файл письма:"), array("type" => CMSFORM_TYPE_TEXT, "name" => "curfile", "label" => "Текущий файл:", "value" => basename(getFileNameById($ord["filelink"])), "options" => array("html" => "readonly")))); $form->show();
public function lanchsl($rec) { extract($rec); if ($dozap === true) { $numbp = $ppart; } elseif ($dozap == "zadel") { $numbp = $dozapnumbers["use"]; } else { $numbp = $zagotovokvsego <= $zagotinparty ? $numbers : ($last ? $numbers - ($party - 1) * $zagotinparty * $platonblock : $zagotinparty * $platonblock); } $userid = Auth::getInstance()->getUser("userid"); $sql = "UPDATE lanch\r\n SET ldate=NOW(), block_id='{$block_id}',\r\n numbz='{$zag}', numbp='{$numbp}',\r\n user_id='{$userid}', part='{$party}',\r\n tz_id='{$tzid}', pos_in_tz='{$posintz}'\r\n WHERE id='{$lanch_id}'"; sql::query($sql); // если все запущены - исключить из запуска // если из задела тоже if ($dozap !== true) { // обновим таблицу запусков $sql = "DELETE FROM lanched WHERE block_id='{$block_id}'"; sql::query($sql); $sql = "INSERT INTO lanched (block_id,lastdate) VALUES ('{$block_id}',NOW())"; sql::query($sql); $sql = "SELECT SUM(numbz) AS snumbz FROM lanch WHERE pos_in_tz_id='{$posid}'\r\n GROUP BY pos_in_tz_id"; $rs = sql::fetchOne($sql); if ($rs[snumbz] >= $zagotovokvsego) { $sql = "UPDATE posintz SET ldate=NOW() WHERE id='{$posid}'"; sql::query($sql); } } return true; }
public function getOst($id) { $sql = "SELECT * FROM {$this->db}sk_arc_{$this->sklad}_ost WHERE spr_id='{$id}'"; return sql::fetchOne($sql); }
public function getNeedArc() { $sql = "SELECT YEAR(NOW())>(YEAR(sk_{$this->sklad}_dvizh_arc.ddate)+1) AS need\n FROM {$this->db}sk_{$this->sklad}_dvizh_arc\n ORDER BY ddate DESC LIMIT 1"; $rs = sql::fetchOne($sql); return $rs[need]; }
public function arc() { // годовая архивация // перенести движения $sql = "INSERT INTO {$this->db}sk_{$this->sklad}_dvizh_arc\n (type,numd,numdf,docyr,spr_id,quant,ddate,post_id,comment_id,price)\n SELECT sk_{$this->sklad}_dvizh.type,sk_{$this->sklad}_dvizh.numd,sk_{$this->sklad}_dvizh.numdf,sk_{$this->sklad}_dvizh.docyr,sk_{$this->sklad}_dvizh.spr_id,sk_{$this->sklad}_dvizh.quant,sk_{$this->sklad}_dvizh.ddate,sk_{$this->sklad}_dvizh.post_id,sk_{$this->sklad}_dvizh.comment_id,sk_{$this->sklad}_dvizh.price\n FROM {$this->db}sk_{$this->sklad}_dvizh"; if (!sql::query($sql)) { return false; } // очистить движения $sql = "TRUNCATE TABLE {$this->db}sk_{$this->sklad}_dvizh"; if (!sql::query($sql)) { return false; } $sql = "SELECT * FROM {$this->db}sk_{$this->sklad}_spr"; $res = sql::fetchAll($sql); foreach ($res as $rs) { $id = $rs["id"]; // получить остатки $sql = "SELECT * FROM {$this->db}sk_{$this->sklad}_ost WHERE sk_{$this->sklad}_ost.spr_id='{$id}'"; $ost = mysql_fetch_array(mysql_query($sql)); $ost = $ost["ost"]; // создать архивное движение // поставщик $sql = "SELECT id FROM {$this->db}sk_{$this->sklad}_postav WHERE supply=''"; $rs1 = sql::fetchOne($sql); if (!empty($rs1)) { $post_id = $rs1["id"]; } // коментарий $sql = "SELECT id FROM {$this->db}coments WHERE comment='Передача остатка'"; $rs1 = sql::fetchOne($sql); if (!empty($rs1)) { $comment_id = $rs1["id"]; } else { $sql = "INSERT INTO {$this->db}coments (comment) VALUES ('Передача остатка')"; sql::query($sql) or die(sql::error(true)); $comment_id = sql::lastId(); } $numd = "9999"; $numdf = "9999"; $docyr = date("Y") - 1; $ddate = date("Y-m-d", mktime(0, 0, 0, 12, 31, $docyr)); $sql = "INSERT INTO {$this->db}sk_{$this->sklad}_dvizh_arc (type,numd,numdf,docyr,spr_id,quant,ddate,post_id,comment_id,price)\n VALUES ('0','{$numd}','{$numdf}','{$docyr}','{$id}','{$ost}','{$ddate}','{$post_id}','{$comment_id}','0')"; echo $sql . "<br>"; if (!sql::query($sql)) { return false; } // создадим первое движение года // коментарий $sql = "SELECT id FROM {$this->db}coments WHERE comment='Остаток на 31.12.{$docyr}'"; $rs1 = sql::fetchOne($sql); if (!empty($rs1)) { $comment_id = $rs1["id"]; } else { $sql = "INSERT INTO {$this->db}coments (comment) VALUES ('Остаток на 31.12.{$docyr}')"; sql::query($sql) or die(sql::error(true)); $comment_id = sql::lastId(); } $docyr = date("Y"); $ddate = date("Y-m-d", mktime(0, 0, 0, 1, 1, $docyr)); $sql = "INSERT INTO {$this->db}sk_{$this->sklad}_dvizh (type,numd,numdf,docyr,spr_id,quant,ddate,post_id,comment_id,price)\n VALUES ('1','{$numd}','{$numdf}','{$docyr}','{$id}','{$ost}','{$ddate}','{$post_id}','{$comment_id}','0')"; if (!sql::query($sql)) { return false; } } return true; }
*/ $uid = $edit; $form = new Edit($processing_type); $form->init(); $sql = "SELECT * FROM rtypes ORDER BY type"; $res = sql::fetchAll($sql); $sql = "SELECT * FROM rrtypes"; $res1 = sql::fetchAll($sql); foreach ($res as $rs) { $label = sprintf("<span id='rrr' rtype='" . $rs["type"] . "'>[%-10s]</span>:", $rs["type"]); $name = "r|" . $rs["id"] . ""; //sprintf("[%-10s]:",$rs["type"]); //echo $name."<br>"; foreach ($res1 as $rs1) { $sql = "SELECT * FROM rights WHERE type_id='" . $rs["id"] . "' AND u_id='{$uid}' AND rtype_id='" . $rs1["id"] . "'"; $rs2 = sql::fetchOne($sql); //echo $rs1["rtype"]."-<input type=checkbox name=r[".$rs["id"]."][".$rs1["id"]."] ".($rs2["right"]=='1'?"checked":"").">"; $value[$rs1["id"]] = $rs2["right"] == 1 ? 1 : 0; $values[$rs1["id"]] = '-'; } //print_r($value); $form->addFields(array(array("type" => CMSFORM_TYPE_CHECKBOXES, "name" => $name, "label" => $label, "value" => $value, "values" => $values, "options" => array("nobr" => true, "html" => " rtype=" . $rs["type"] . " ")))); unset($values); unset($value); } $form->addFields(array(array("type" => CMSFORM_TYPE_HIDDEN, "name" => "userid", "value" => $uid))); $form->show(); echo "<script>\$('#rrr').live('click',function(){\$(':checkbox[rtype='+\$(this).attr('rtype')+']').attr('checked',true);});</script>"; echo "<script>\$('#rrr').live('dblclick',function(){\$(':checkbox[rtype='+\$(this).attr('rtype')+']').attr('checked',false);});</script>"; } elseif (isset($delete)) { // удаление
public function createTZ($rec) { extract($rec); // np не надо редактировать - только добавлять с текущей датой и пользователем // определим позицию в письме extract($_SESSION[Auth::$lss]); //list($customer_id,$order_id,$tz_id,$posintzid) = explode(':',$idstr); $orderid = $order_id; $sql = "SELECT COUNT(*)+1 AS next FROM tz WHERE order_id='{$orderid}'"; $rs = sql::fetchOne($sql); $pos_in_order = $rs[next]; // добавление // создать файл с табличкой // определим заказчика $sql = "SELECT number,orderdate,customer, fullname\n FROM orders\n JOIN customers\n ON customers.id=customer_id\n WHERE orders.id='{$orderid}'"; //echo $sql; $rs = sql::fetchOne($sql); $order = $rs["number"]; $customer = $rs["customer"]; $fullname = $rs["fullname"]; $odate = $rs["orderdate"]; $cdate = date("m-d-Y"); $sql = "INSERT INTO tz (order_id,tz_date,user_id) VALUES ('{$orderid}',NOW(),'" . Auth::getInstance()->getUser('id') . "')"; sql::query($sql); $tzid = sql::lastId(); do { $filetype = $typetz == "mpp" ? "МПП" : ($typetz == "dpp" ? "ДПП" : ($typetz == "mppb" ? "МПП-Блок" : "ДПП-Блок")); $orderstring = fileserver::removeOSsimbols($rs["number"]); $file_link = "t:\\\\Расчет стоимости плат\\\\ТехЗад\\\\{$customer}\\\\{$tzid}-{$filetype}-{$pos_in_order}-{$orderstring} от {$rs["orderdate"]}.xls"; $filename = fileserver::createdironserver($file_link); $fe = file_exists($filename); if ($fe) { $pos_in_order++; } } while ($fe); // Определим идентификатор файловой ссылки $file_id = $this->getFileId($file_link); // добавить поля в $sql = "UPDATE tz SET file_link_id='{$file_id}', pos_in_order='{$pos_in_order}' WHERE id='{$tzid}'"; sql::query($sql); $rec = array('id' => $tzid, 'tzlink' => $file_link, 'success' => true); $tzid = sprintf("%08s", $tzid); // для отображения в заказе $rec = array_merge($rec, compact('cdate', 'filename', 'order', 'odate', 'typetz', 'fullname', 'tzid')); return $rec; }
public function getRecord($id) { $sql = "SELECT *, customers.id AS cusid, conductors.board_id AS plid\n FROM conductors\n JOIN (customers,boards)\n ON (\n conductors.board_id=boards.id\n AND boards.customer_id=customers.id\n )\n WHERE conductors.id='{$id}'"; $rec = sql::fetchOne($sql); return $rec; }
if (empty($rs)) { $sql = "INSERT INTO coppers \n (scomp,ssolder,drlname,customer_id,plate_id,sizex,sizey) \n VALUES \n ('{$comp}','{$solder}','{$drillname}','{$customer_id}',\n '{$plate_id}','{$sizex}','{$sizey}')"; sql::query($sql) or die(sql::error(true)); } else { $sql = "UPDATE coppers SET \n scomp='{$comp}', ssolder='{$solder}', drlname='{$drillname}', \n sizex='{$sizex}', sizey='{$sizey}' \n WHERE customer_id='{$customer_id}' AND plate_id='{$plate_id}'"; sql::query($sql) or die(sql::error(true)); } // изменения в блоки $sql = "SELECT id FROM blocks \n WHERE customer_id='{$customer_id}' AND blockname='{$board}'"; $rs = sql::fetchOne($sql); if (empty($rs)) { $sql = "INSERT INTO blocks \n (scomp,ssolder,drlname,customer_id,blockname,sizex,sizey) \n VALUES \n ('{$comp}','{$solder}','{$drillname}',\n '{$customer_id}','{$board}','{$sizex}','{$sizey}')"; sql::query($sql) or die(sql::error(true)); } else { $plate_id = $rs["id"]; $sql = "UPDATE blocks SET \n scomp='{$comp}', ssolder='{$solder}', drlname='{$drillname}', \n sizex='{$sizex}', sizey='{$sizey}' WHERE id='{$plate_id}'"; sql::query($sql) or die(sql::error(true)); } // а тепрерь созадидим фал копирования сверловок $sql = "SELECT kdir FROM customers WHERE id='{$customer_id}'"; $rs = sql::fetchOne($sql); if (empty($rs)) { if ($customer == "Импульс") { $rs[kdir] .= "\\{$drillname}"; $mpp = -1; } echo "mkdir k:\\" . $rs[0] . ($mpp != -1 ? "\\MPP" : "") . "\\\n"; echo "copy /Y .\\{$drillname}.mk2 k:\\" . $rs[0] . ($mpp != -1 ? "\\MPP" : "") . "\\\n"; echo "copy /Y .\\{$drillname}.mk4 k:\\" . $rs[0] . ($mpp != -1 ? "\\MPP" : "") . "\\\n"; echo "copy /Y .\\{$drillname}.frz k:\\" . $rs[0] . ($mpp != -1 ? "\\MPP" : "") . "\\\n"; }
/** * Проверка сессии получене данных о пользователе * @var string $sessionid Идентификатор сессии * @return array */ public function checksession($sessionid) { $rec = array(); $sql1 = "SELECT * FROM session " . "WHERE session ='{$sessionid}'"; $rs = sql::fetchOne($sql1); if (!empty($rs)) { // не бывает, в авторизации записываем 0 на неудаче if ($rs["u_id"] != 0) { $sql = "SELECT * FROM users " . "WHERE id='{$rs["u_id"]}'"; $rs = sql::fetchOne($sql); if (!empty($rs)) { $rec["user"]["username"] = $rs["nik"]; $rec["user"]["userid"] = $rs["id"]; $rec["user"]["user_id"] = $rs["id"]; $rec["user"]["u_id"] = $rs["id"]; $rec["user"]["id"] = $rs["id"]; $sql = "UPDATE session SET ts=NOW() WHERE session='{$sessionid}'"; sql::query($sql); // права if (empty($_SESSION["rights"])) { $sql = "SELECT rights.right,type,rtype FROM rights " . "JOIN (rtypes,rrtypes) " . "ON (rtypes.id=type_id " . "AND rrtypes.id=rtype_id) " . "WHERE u_id='{$rs["id"]}'"; $res = sql::fetchAll($sql); foreach ($res as $rs) { if ($rs["right"] == '1') { $_SESSION["rights"][$rs["type"]][$rs["rtype"]] = true; } } } $rec["rights"] = $_SESSION["rights"]; $rec["success"] = 'Auth.session.success'; // определимся с сессией окна Auth::$lss = !empty($_REQUEST["lss"]) ? $_REQUEST["lss"] : "lss"; } else { $rec["success"] = 'Auth.session.cantfinduser'; } } else { // нет пользователя $rec["success"] = 'Auth.session.wrongpassword'; } } else { // не оказалось сессии в базе $rec["success"] = 'Auth.session.nosession'; } $rec["mes"] .= Lang::getString($rec["success"]); return $rec; }