Viewing file: module.php (4.9 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<? class Regulatory { var $UserMode = true; var $AdminMode = true; var $SearchMode = false; var $PanelMode = false; var $AdminAsynchMode = true; var $Table; var $ClassName = 'Regulatory'; var $Directory; function Regulatory() { $this->Directory = dirname(__FILE__); $this->Table = new AMTable2('AMCMS_regulatory'); $this->Table->Module($this->ClassName); $this->Table->AddIndexField("doc_id"); $this->Table->AddPositionField("doc_position"); } function User() { global $ulang, $ULANG; $rows = $this->Table->GetRows("doc_position DESC"); $smarty = GetUserSmarty($this->ClassName); $smarty->assign('rows', $rows); $smarty->assign('mod', $this->ClassName); $result['Content'] = $smarty->fetch("docs.tpl"); $modName = GetParam('Module'.$this->ClassName, $ulang); $navigator = new AMNavigator(); $navigator->AddLink($modName, "/actual"); $result['GlobalParams']['Navigator'] = $navigator->Fetch(); $result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage(); $result['Module'] = $this->ClassName; $result['Print'] = true; $result['Title'] = ($year == 0) ? $modName : $modArchiveName; return $result; } function Menu() { global $ALANG; return array( array('title' => $ALANG['LawsMenuAdd'], 'link' => '?mod='.$this->ClassName.'&add'), array('title' => $ALANG['LawsMenuList'], 'link' => '?mod='.$this->ClassName.'&list'), ); } function Admin() { global $ALANG, $DefaultAdminLanguage, $_LANG_ID; $smarty = GetAdminSmarty($this->ClassName); if (isset($_GET['list'])) { $fields = array("doc_title_ukr"); $captions = array(""); $conditions = "true"; $order = "doc_position DESC"; $links = array("checkbox", "delete", "edit"); $multiple = array("delete"); $params = array("sortable" => "yes", "id" => "regulatory"); $html = $this->Table->GetAdminTable($fields, $captions, $conditions, $order, $links, $multiple, $params); $result['Title'] = $ALANG['LawsList']; $result['Content'] = $html; return $result; } if (isset($_GET['add'])) { if (isset($_POST['oper']) && ($_POST['oper'] == 'add')) { $str = array('', '_project', '_analiz', '_rezult', '_ressenie'); $id = $this->Table->Insert($_POST); for ($i = 1; $i <= 4; $i++) if (strlen($_FILES["file{$i}"]["name"]) > 0) { $path_info = pathinfo($_FILES["file{$i}"]['name']); $_POST["doc_file{$i}"] = "doc{$id}{$str[$i]}.".$path_info['extension']; move_uploaded_file($_FILES["file{$i}"]['tmp_name'], "data/regulatory/".$_POST["doc_file{$i}"]); } $this->Table->Update($_POST, $id); header("Location: ?mod=".$this->ClassName."&list"); } $smarty = GetAdminSmarty($this->ClassName); foreach($_POST as $key => $value) $smarty->assign($key, $value); $smarty->assign('oper', 'add'); $result['Title'] = $ALANG['LawsDocumentAdd']; $result['Content'] = $smarty->fetch('doc.tpl'); return $result; } if (isset($_GET['edit']) && isset($_GET['doc_id'])) { $id = $_GET['doc_id']; $row = $this->Table->GetRowById($id); if (isset($_POST['oper']) && ($_POST['oper'] == 'edit')) { $str = array('', '_project', '_analiz', '_rezult', '_ressenie'); for ($i = 1; $i <= 4; $i++) { if ($_POST["doc{$i}"] == "del") { @unlink("/data/regulatory/".$row["doc_file{$i}"]); $_POST["doc_file{$i}"] = ""; } } for ($i = 1; $i <= 4; $i++) if (strlen($_FILES["file{$i}"]["name"]) > 0) { $path_info = pathinfo($_FILES["file{$i}"]['name']); $_POST["doc_file{$i}"] = "doc{$id}{$str[$i]}.".$path_info['extension']; @unlink("/data/regulatory/".$row["doc_file{$i}"]); move_uploaded_file($_FILES["file{$i}"]['tmp_name'], "data/regulatory/".$_POST["doc_file{$i}"]); } $this->Table->Update($_POST, $id); header("Location: ?mod=".$this->ClassName."&list"); } foreach($row as $key => $value) $smarty->assign($key, $value); $smarty->assign('oper', 'edit'); $result['Title'] = $ALANG['LawsEdition']; $result['Content'] = $smarty->fetch('doc.tpl'); return $result; } }
function AdminAsynch() { global $DefaultAdminLanguage, $ALANG; if (isset($_POST['oper']) && ($_POST['oper'] == 'toarchive')) { $id = $_POST['id']; $row['actual_date_of_archiving'] = GetCurrentDateAndTime(); $row['actual_type'] = 2; $this->Table->Update($row, $id); $res["status"] = "ok"; $res["code"] = $id; echo json_encode($res); die; } if (isset($_POST['oper']) && ($_POST['oper'] == 'fromarchive')) { $id = $_POST['id']; $row['actual_date_of_archiving'] = ""; $row['actual_type'] = 1; $this->Table->Update($row, $id); $res["status"] = "ok"; $res["code"] = $id; echo json_encode($res); die; } $this->Table->Run($_POST); } }
$Modules ['Regulatory'] = new Regulatory(); ?>
|