public static function SheetUpdate(Ab_Database $db, $d) { if (count($d->arrStudId) > 0) { $addlistid = $d->arrStudId; //массив добавления студентов $rows = RecordBookQuery::StudidListFromMark($db, $d->idSheet); $remlistid = array(); //массив удаления студентов while ($dd = $db->fetch_array($rows)) { $isRemove = true; foreach ($addlistid as $key => $id) { if ($id == $dd['id']) { $isRemove = false; unset($addlistid[$key]); break; } } if ($isRemove) { $remlistid[] = $dd['id']; } } if (count($remlistid) > 0) { $remstr = implode(',', $remlistid); $sql = "\n\t\t\t\t\t\tDELETE FROM " . $db->prefix . "rb_marks\n\t\t \t\t\tWHERE sheetid=" . bkint($d->idSheet) . " AND studid IN (" . $remstr . ")\n\t\t\t\t"; $db->query_write($sql); } if (count($addlistid) > 0) { RecordBookQuery::AppendMarks($db, $addlistid, $d->idSheet); } } $sql = "\n\t\t\t\tUPDATE " . $db->prefix . "rb_sheet\n\t\t\t\tSET\n\t\t\t\t\tdate=" . bkint($d->date) . ",\n\t\t\t\t\tteacherid=" . bkint($d->teacherid) . "\n\t\t\t\tWHERE sheetid=" . bkint($d->idSheet) . "\n\t\t\t\tLIMIT 1\n\t\t"; $db->query_write($sql); }
public function SheetItem($d) { $d->sheetid = intval($d->sheetid); $row = RecordBookQuery::SheetItemlist($this->db, $d->sheetid); if ($row['type'] == 2 || $row['type'] == 4) { $arrStudId = array(); $studid = RecordBookQuery::StudidListFromMark($this->db, $row['id']); while ($dd = $this->db->fetch_array($studid)) { $arrStudId[] = $dd['id']; } $row['arrstudid'] = $arrStudId; } if ($row['type'] >= 3) { $row['formcontrol'] = $this->DetermFormControl($row['project']); } if (isset($d->mark)) { if ($d->mark === true) { $row['attestation'] = array($row['firstattproc'], $row['secondattproc'], $row['thirdattproc']); } } return $this->models->InstanceClass('SheetItem', $row); }