public function getRasschet($rec) { extract($rec); $filelink = fileserver::createdironserver($filename); $excel = file_get_contents($this->getDir() . "/" . $template); if (fileserver::savefile($filelink . ".txt", $rec)) { // сохранить if (fileserver::savefile($filelink, $excel)) { Output::assign('rlink', fileserver::sharefilelink($filelink)); $out = $this->fetch('rlink.tpl'); $res[filename] = $filename; $res[result] = true; } else { $out = "Не удалось записать файл xls"; $res[result] = false; } } else { $out = "Не удалось создать файл txt"; $res[result] = false; } $res[out] = $out; return $res; }
public function setRecord($rec) { extract($rec); /* Поля в ТЗ для дпп blockname blocks numbers posintz first posintz srok posintz type boards class boards priem posintz complexity_factor boards boardsizex boards boardsizey boards blocksizex blocks blocksizey blocks numonblock blocks numblock valuetion constr posintz template_check posintz template_make posintz drills(smalldrill/bigdrill) blocks textolite boards thickness boards mask boards mark boards rmark boards razr boards frezcorner boards frez_factor lamel boards numlam boards lsizex boards lsizey boards immer boards auarea blocks boardcomment blocks posintcomment posintz */ $rec[first] = '0'; // если вставляем старую плату, а сейчас мы так и делаем $sql = "SELECT * FROM posintz WHERE block_id='{$block_id}' ORDER BY id DESC LIMIT 1"; $pos = sql::fetchOne($sql); if (empty($pos)) { $res[alert] = "Не запускалось такого Новая наверное. Ручками давай."; $res[affected] = false; return $res; } // определим позицию добавленного в тз $posintz = array(1, 2, 3); $sql = "SELECT posintz FROM posintz WHERE tz_id='{$tz_id}'"; $rsn = sql::fetchAll($sql); if (!empty($rsn)) { foreach ($rsn as $value) { // тут может быть 1 2 или 3 $posintz = array_diff($posintz, array($value["posintz"])); } if (empty($posintz)) { $res[alert] = "Не лезет. Уже три позиции запихал"; $res[affected] = false; return $res; } else { $posintz = reset($posintz); } } else { $posintz = 1; } // получить данные блока $block = new orders_blocks_model(); $block = $block->getRecord($block_id); // получить данны плат в блоке $board = $block[blockpos][0]; // добавить позицию в таблицу posintz $newpos[tz_id] = $tz_id; $newpos[posintz] = $posintz; $newpos[block_id] = $block_id; $newpos[numpl1] = $newpos[numbers] = $board_num; $newpos[numbl] = $newpos[numblock] = ceil($board_num / $board[nib]); $newpos[first] = 0; // так как мы добавляем из старой $newpos[srok] = $pos[srok]; $newpos[priem] = $pos[priem]; $newpos[constr] = 1; //$pos[constr]; //один час при повторе $newpos[template_check] = max(array($pos[template_check], $pos[template_make])); $newpos[template_make] = 0; $newpos[comment_id] = $pos[comment_id]; sql::insertUpdate($this->maintable, array($newpos)); // дозаполнить newpos $newpos[blockname] = $block[blockname]; $newpos[type] = $board[layers] == 1 ? "ОПП" : "ДПП"; // пока будет так $newpos[layers] = $board[layers]; $newpos["class"] = $board["class"]; $newpos[complexity_factor] = $board[complexity_factor] > 0 ? $board[complexity_factor] : ""; $newpos[boardsizex] = $board[sizex]; $newpos[boardsizey] = $board[sizey]; $newpos[blocksizex] = ceil($block[sizex]); $newpos[blocksizey] = ceil($block[sizey]); $newpos[numonblock] = $board[nib]; $newpos[drills] = "{$block[smalldrill]}/{$block[bigdrill]}"; $newpos[textolite] = $board[textolite]; $newpos[glasscloth] = $board[glasscloth]; $newpos[thickness] = $board[thickness]; preg_match('/(?P<nummask>[+0-9]*)(?P<mask>.*)/i', $board[mask], $matches); $newpos[mask] = $matches[mask]; $newpos[nummask] = empty($matches[nummask]) ? 2 : $matches[nummask]; $newpos[mark] = $board[mark]; $newpos[rmark] = $board[rmark]; $newpos[razr] = $board[razr]; $newpos[frezcorner] = $board[frezcorner]; $newpos[frez_factor] = $board[frez_factor] > 0 ? $board[frez_factor] : "1.0"; $newpos[lamel] = $board[numlam] > 0 ? "{$board[numlam]} {$board[lsizex]}x{$board[lsizey]}" : "0 0.0x0.0"; $newpos[numlam] = $board[numlam]; $newpos[lsizex] = $board[lsizex]; $newpos[lsizey] = $board[lsizex]; $newpos[immer] = $board[immer]; $newpos[auarea] = $board[immer] == 1 ? $block[auarea] : ""; // блоки с JSON $params = json_decode(multibyte::Unescape(sqltable_model::getComment($block["comment_id"])), true); //получим текщий комент из блока $newpos[boardcomment] = $params[coment]; $newpos[eltest] = $params[eltest]; $newpos[etpib] = $params[etpib]; $newpos[etpoints] = $params[etpoints]; $newpos[etcompl] = $params[etcompl]; $newpos[posintcomment] = $this->getComment($pos[comment_id]); // сохранить данные в файл $tz = new orders_tz_model(); $tz = $tz->getRecord($tz_id); $filelink = $tz[tzlink]; $filename = fileserver::createdironserver($filelink); fileserver::savefile("{$filename}.{$posintz}.txt", $newpos); // вывести ссылочку или не надо... $res[affected] = true; return $res; }
public function showmplink($rec) { $filename = "z:\\Заказчики\\{$rec[customer]}\\{$rec[blockname]}\\Мастерплаты\\МП-{$rec[date]}-{$rec[mp_id]}.xls"; $filename = fileserver::createdironserver($filename); $excel = file_get_contents($this->getDir() . "/mp.xls"); if (fileserver::savefile($filename, $excel)) { $mp["_date_"] = date("d.m.Y"); $mp["_number_"] = sprintf("%08d\n", $rec[mp_id]); if (fileserver::savefile($filename . ".txt", $mp)) { Output::assign('mplink', fileserver::sharefilelink($filename)); Output::assign('mpid', $rec[mp_id]); $out = $this->fetch('mplink.tpl'); } else { $out = "Не удалось создать файл txt"; } } else { $out = "Не удалось создать файл xls" . print_r($rec, true); } return $out; }