Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 public function setRecord($data)
 {
     // поля с именами совпадающими с именами полей таблицы добавляем в базу
     $data["id"] = $data["edit"];
     $ret[affected] = sql::insertUpdate($this->maintable, array($data));
     // файлы к таблице привязать
     $files = $data["files"];
     $files = $this->storeFiles($files, $this->maintable);
     // TODO: отработать false значение $files
     $curfile = $data["curfile"];
     if (!isset($curfile)) {
         $curfile = array();
     }
     $linkfile = $data["linkfile"];
     if (!isset($linkfile)) {
         $linkfile = array();
     }
     $curfile = $curfile + $linkfile + $files;
     // в мерге перенумеровываются ключи!!!
     $this->storeFilesInTable($curfile, $this->maintable, $data[edit]);
     $ret[affected] = true;
     return $ret;
 }
Ejemplo n.º 3
0
 /**
  * Сохраняет или обновляет данные о расчете цены в таблице 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;
 }
Ejemplo n.º 4
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;
 }