Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
    static function cleanSessionCache() {

        $path = AJAXFORM_CACHE;

        fileserver::createdironserver($path);

        $dirs = glob($path . "/*", GLOB_NOSORT | GLOB_ONLYDIR);

        if (is_array($dirs) && count($dirs))
            foreach ($dirs as $e) {

                $files = glob($e . "/*.php", GLOB_NOSORT);

                if (is_array($files) && count($files))
                    foreach ($files as $f) {

                        if (@filemtime($f) < time() - AJAXFORM_CACHE_LIFETIME)
                            @unlink($f);
                    }

                @rmdir($e);
            }
    }
Exemplo n.º 4
0
 public function getSl($rec)
 {
     if ($rec[dpp]) {
         $rec = $this->getSlDpp($rec);
     } else {
         $rec = $this->getSlMpp($rec);
     }
     extract($rec);
     // Определим идентификатор файловой ссылки
     $rec["l_date"] = $l_date = date("Y-m-d");
     $file_link = "z:\\Заказчики\\{$customer}\\{$blockname}\\запуски\\" . "СЛ-{$l_date}-{$lanch_id}.xml";
     $rec["template"] = $dpp ? "/sldpp.xls" : "/slmpp{$class}.xls";
     $fileext = explode(".", $rec["template"]);
     $rec["fileext"] = $fileext[1];
     $rec["file_link"] = str_replace("xml", $rec["fileext"], $file_link);
     $rec["filename"] = fileserver::createdironserver($rec["file_link"]);
     $rec[file_id] = $file_id = $this->getFileId($rec["file_link"]);
     $sql = "UPDATE lanch\r\n                SET file_link_id='{$file_id}'\r\n                WHERE id='{$lanch_id}'";
     sql::query($sql);
     return $rec;
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 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;
 }