public function edit($id) {
if(!empty($id)){
$data = $this->db->query("SELECT * FROM ?t WHERE uchgraph_id=?",array("time_uchgraph",$id),"rowassoc");
$data["unit_code"] = $this->unit($data["unit_id"],"unit_code");
$data["unit_profile"] = $this->unit($data["unit_id"],"unit_profile");
$data["codes"] = $this->db->query("SELECT distinct d.discipline_id,(select name from time_disciplines WHERE code like d.discipline_id) as discipline_name FROM ?t d WHERE d.uchgraph_id=?",array("time_graph",$id),"assoc");
foreach ($data["codes"] as &$value) {
$value["sim1"] = $this->db->query("SELECT * FROM ?t WHERE uchgraph_id=? and sim=1 and discipline_id=?",array("time_graph",$id,$value["discipline_id"]),"rowassoc");
$value["sim2"] = $this->db->query("SELECT * FROM ?t WHERE uchgraph_id=? and sim=2 and discipline_id=?",array("time_graph",$id,$value["discipline_id"]),"rowassoc");
}
$this->smarty->assign("data", $data);
}
$item = $this->db->query("SELECT * FROM ?t WHERE unit_id=?",array("time_unit",$_SESSION["kafedra"]),"rowassoc");
$this->smarty->assign("kaf", $item);
$direct = $this->db->query("SELECT * FROM ?t WHERE unit_pid=? and unit_type in (40,35)",array("time_unit",$_SESSION["kafedra"]),"assoc");
$this->smarty->assign("direct", $direct);
$special = $this->db->query("SELECT * FROM ?t WHERE unit_pid=? and unit_type in (50)",array("time_unit",$_SESSION["kafedra"]),"assoc");
$this->smarty->assign("special", $special);
$this->smarty->assign("page_title","Графики учебных занятий");
$this->smarty->assign("tmpl_name", "graph/edit");
}
public function unit($id,$col = null){
if(!empty($col)){
return $this->db->query("SELECT ?c FROM time_unit WHERE unit_id=?",array($col,$id),"el");
}else{
return $this->db->query("SELECT * FROM time_unit WHERE unit_id=?",array($id),"rowassoc");
}
}