public function __construct()
 {
     /*if (!template_session::is_admin() and !template_session::is_editor())
     		{
     			if (get('ajax'))
     			{
     				exit(RUDE_AJAX_ACCESS_VIOLATION);
     			}
     
     			return false;
     		}*/
     switch (get('task')) {
         case 'save':
             $status = settings::save(get('popup_id'), get('popup'), get('rector_id'), get('rector'));
             template_session::set_use_popup(get('popup'));
             break;
         default:
             $status = false;
             break;
     }
     if (get('ajax')) {
         if ($status) {
             exit(RUDE_AJAX_OK);
         } else {
             exit(RUDE_AJAX_ERROR);
         }
     }
     return true;
 }
 public function __construct()
 {
     if (!template_session::is_admin() and !template_session::is_editor()) {
         if (get('ajax')) {
             exit(RUDE_AJAX_ACCESS_VIOLATION);
         }
         return false;
     }
     switch (get('task')) {
         case 'remove':
             $status = departments::remove(get('id'));
             break;
         case 'add':
             $status = departments::add(get('name'));
             break;
         case 'edit':
             $status = departments::edit(get('id'), get('name'));
             break;
         default:
             $status = false;
             break;
     }
     if (get('ajax')) {
         if ($status) {
             exit(RUDE_AJAX_OK);
         } else {
             exit(RUDE_AJAX_ERROR);
         }
     }
     return true;
 }
 public static function login($user_id = null)
 {
     if ($user_id === null) {
         $user_id = template_session::get_user_id();
     }
     if (!$user_id) {
         return false;
     }
     $user = users::get($user_id);
     if (!$user) {
         return false;
     }
     template_session::set_user_id($user->id);
     template_session::set_user_name($user->name);
     $setting_popup = settings::get_popup($user->id);
     template_session::set_use_popup($setting_popup->value);
     switch ($user->role_id) {
         case RUDE_ROLE_ADMIN:
             template_session::set_authorized();
             template_session::set_admin();
             template_session::set_editor();
             template_session::set_user();
             break;
         case RUDE_ROLE_EDITOR:
             template_session::set_authorized();
             template_session::set_editor();
             template_session::set_user();
             break;
         case RUDE_ROLE_USER:
             template_session::set_authorized();
             template_session::set_user();
             break;
     }
     return true;
 }
 public static function init()
 {
     $username = get('username');
     $password = get('password');
     if (!$username) {
         exit('Пожалуйста, укажите имя для пользователя.');
     }
     if (!$password) {
         exit('Пожалуйста, укажите пароль пользователю.');
     }
     if (string::length($password) < 6) {
         exit('Ваш пароль не может быть менее 6 символов.');
     }
     $user = users::get_by_name($username);
     if (!$user) {
         exit('Данного пользователя не существует.');
     }
     if (!crypt::is_valid($password, $user->hash, $user->salt)) {
         exit('Указанный вами пароль не совпадает с тем, что был указан при регистрации.');
     }
     $is_authorized = template_session::login($user->id);
     if (!$is_authorized) {
         exit('Нарушение логической цепи: авторизация не произведена.');
     }
 }
 public static function init()
 {
     if (!template_session::is_admin() and !template_session::is_editor()) {
         if (get('ajax')) {
             exit(RUDE_AJAX_ACCESS_VIOLATION);
         }
         return false;
     }
     switch (get('task')) {
         case 'save':
             static::save();
             exit;
         default:
             break;
     }
     return true;
 }
 public static function init()
 {
     $username = get('username');
     $password = get('password');
     //$role_id = get('role_id');
     if (!$username) {
         exit('Пожалуйста, укажите имя для пользователя.');
     }
     if (!$password) {
         exit('Пожалуйста, укажите пароль пользователю.');
     }
     if (string::length($password) < 6) {
         exit('Ваш пароль должен быть длиной 6 или более символов.');
     }
     if (users::is_exists($username)) {
         exit('Данный пользователь уже существует. Попробуйте указать другое имя.');
     }
     $user_id = users::add($username, $password, RUDE_ROLE_USER);
     if (!$user_id) {
         exit('Произошла непредвиденная ошибка. Пожалуйста, обратитесь к администратору сайта и расскажите после каких действий вы увидели данное сообщение.');
     }
     settings::add($user_id);
     template_session::login($user_id);
 }
    public static function sidebar()
    {
        template_html::dimmer();
        template_html::registration();
        template_html::authorization();
        template_html::access_violation();
        ?>
		<div id="sidebar">
			<div class="ui vertical menu square-corners">
				<div class="item header" onclick="rude.animate('#navigation'); rude.cookie.toggle('hide_navigation')">
					Навигация
				</div>

				<div id="navigation" <?php 
        if (cookies::is_equals('hide_navigation', 1)) {
            ?>
style="display: none;"<?php 
        }
        ?>
>
					<a class="item subcategory" href="/">
						<i class="icon home"></i> Вернуться на главную
					</a>

					<?php 
        if (!template_session::is_authorized()) {
            ?>
						<a class="item subcategory" href="#" onclick="$('#authorization').modal('show'); return false;">
							<i class="icon sign in"></i> Авторизация
						</a>
					<?php 
        }
        ?>

					<?php 
        if (!template_session::is_authorized()) {
            ?>
						<a class="item subcategory" href="#" onclick="$('#registration').modal('show'); return false;">
							<i class="icon edit"></i> Регистрация
						</a>
					<?php 
        }
        ?>

					<?php 
        if (template_session::is_authorized()) {
            ?>
						<a class="item subcategory" href="#" onclick="$.post('/?page=logout', function() { rude.redirect('/'); }); return false;">
							<i class="icon sign out"></i> Выход
						</a>
					<?php 
        }
        ?>
				</div>


				<?php 
        if (template_session::is_authorized()) {
            ?>
					<div class="item header" onclick="rude.animate('#management'); rude.cookie.toggle('hide_management')">
						Управление
					</div>

					<div id="management" <?php 
            if (cookies::is_equals('hide_management', 1)) {
                ?>
style="display: none;"<?php 
            }
            ?>
>
						<a class="item subcategory <?php 
            if (get('page') == 'departments') {
                ?>
active<?php 
            }
            ?>
" href="/?page=departments">
							<i class="icon"></i> Кафедры
						</a>

						<a class="item subcategory <?php 
            if (get('page') == 'faculties') {
                ?>
active<?php 
            }
            ?>
" href="/?page=faculties">
							<i class="icon"></i> Факультеты
						</a>

						<a class="item subcategory <?php 
            if (get('page') == 'qualifications') {
                ?>
active<?php 
            }
            ?>
" href="/?page=qualifications">
							<i class="icon"></i> Квалификации
						</a>

						<a class="item subcategory <?php 
            if (get('page') == 'specializations') {
                ?>
active<?php 
            }
            ?>
" href="/?page=specializations">
							<i class="icon"></i> Специализации
						</a>

						<a class="item subcategory <?php 
            if (get('page') == 'specialties') {
                ?>
active<?php 
            }
            ?>
" href="/?page=specialties">
							<i class="icon"></i> Специальности
						</a>

						<a class="item subcategory <?php 
            if (get('page') == 'users') {
                ?>
active<?php 
            }
            ?>
" href="/?page=users">
							<i class="icon"></i> Пользователи
						</a>

						<a class="item subcategory <?php 
            if (get('page') == 'calendar_legend') {
                ?>
active<?php 
            }
            ?>
" href="/?page=calendar_legend">
							<i class="icon"></i> Условные обозначения
						</a>

						<a class="item subcategory <?php 
            if (get('page') == 'directions') {
                ?>
active<?php 
            }
            ?>
" href="/?page=directions">
							<i class="icon"></i> Направления
						</a>

						<a class="item subcategory <?php 
            if (get('page') == 'settings') {
                ?>
active<?php 
            }
            ?>
" href="/?page=settings">
							<i class="icon"></i> Настройки
						</a>

						<a class="item subcategory <?php 
            if (get('page') == 'stats') {
                ?>
active<?php 
            }
            ?>
" href="/?page=stats">
							<i class="icon"></i> База данных
						</a>
					</div>


					<div class="item header" onclick="rude.animate('#reports'); rude.cookie.toggle('hide_reports')">
						Учебные планы
					</div>

					<div id="reports" <?php 
            if (cookies::is_equals('hide_reports', 1)) {
                ?>
style="display: none;"<?php 
            }
            ?>
>
						<a class="item subcategory <?php 
            if (get('page') == 'reports') {
                ?>
active<?php 
            }
            ?>
" href="/?page=reports">
							<i class="icon"></i> Все планы
						</a>

						<a class="item subcategory <?php 
            if (get('page') == 'reports-edit') {
                ?>
active<?php 
            }
            ?>
" href="/?page=reports-edit">
							<i class="icon"></i> Добавить новый
						</a>
					</div>
				<?php 
        }
        ?>
			</div>
		</div>
	<?php 
    }
 public function __construct()
 {
     if (!template_session::is_admin() and !template_session::is_editor()) {
         if (get('ajax')) {
             exit(RUDE_AJAX_ACCESS_VIOLATION);
         }
         return false;
     }
     $report_id = (int) get('report_id');
     if (!$report_id) {
         $reports = new reports();
         $report_id = $reports::add();
         header('Location: /?page=reports-edit&report_id=' . $report_id);
         die;
     }
     if (get('is_tmp')) {
         $reports = new reports_preview();
     } else {
         $reports = new reports();
     }
     if (!$reports::is_exists($report_id)) {
         new template_404(true);
     }
     $this->report = $reports::get($report_id);
     if (!$this->report) {
         new template_404(true);
     }
     switch (get('task')) {
         case 'update':
             $status = true;
             exit((string) $reports::update(get('report_id'), get('year'), get('duration'), get('rector'), get('registration_number'), get('training_form_id'), get('qualification_id'), get('specialty_id'), get('specialization_id'), get('study_practice'), get('manufact_practice'), get('grad_work'), get('gos_exam')));
             break;
         case 'update_education':
             $q = new uquery(RUDE_DATABASE_TABLE_EDUCATION);
             $q->update('not_save', (int) 0);
             $q->where('id', (int) get('dis_id'));
             $q->query();
             $status = true;
             break;
         case 'update_education_item':
             $q = new uquery(RUDE_DATABASE_TABLE_EDUCATION_ITEMS);
             $q->update('order_num', (int) get('item_order'));
             $q->update('is_optional', (int) get('optional'));
             $q->where('id', (int) get('item_id'));
             $q->query();
             $status = true;
             break;
         case 'delete_item_discipline':
             $q = new dquery(RUDE_DATABASE_TABLE_EDUCATION_ITEMS);
             $q->where('id', (int) get('id'));
             $q->query();
             $status = true;
             break;
         case 'save_education':
             $data = get('data');
             $item_id = get('item_id');
             if (!$data or !$item_id) {
                 return false;
             }
             $education_items = new education_items_values();
             if ($education_items::is_exists($item_id)) {
                 $education_items::remove($item_id);
             }
             $y = 0;
             $id = $item_id[$y];
             foreach ($item_id as $d_id) {
                 $q = new dquery(RUDE_DATABASE_TABLE_EDUCATION_ITEMS_VALUES);
                 $q->where('item_id', $d_id);
                 $q->query();
             }
             $col_num = 1;
             foreach ($data as $item) {
                 if ($item != '') {
                     $education_items::add($id, $item, $col_num);
                 }
                 if ($col_num == 40) {
                     $col_num = 0;
                     $id = $item_id[$y + 1];
                     $y++;
                 }
                 $col_num++;
             }
             //debug($data);
             $status = true;
             break;
         case 'add_education':
             $tmp = education::add(get('report_id'), get('name'));
             $status = true;
             die(json_encode($tmp));
             break;
         case 'remove_education':
             education::remove(get('id'));
             break;
         case 'add_education_item':
             $tmp = education_items::add(get('education_id'), get('name'), get('order'));
             $status = true;
             die(json_encode($tmp));
             break;
         case 'copy_education':
             $education = education::get(get('dis_id'));
             $q = new cquery(RUDE_DATABASE_TABLE_EDUCATION_PREVIEW);
             $q->add('report_id', (int) get('report_id'));
             $q->add('name', $education->name);
             $q->query();
             $new_id = $q->get_id();
             $q = new query(RUDE_DATABASE_TABLE_EDUCATION_ITEMS);
             $q->where('education_id', (int) get('dis_id'));
             $q->query();
             $all_dis = $q->get_object_list();
             foreach ($all_dis as $cur_dis) {
                 $q = new cquery(RUDE_DATABASE_TABLE_EDUCATION_ITEMS_PREVIEW);
                 $q->add('name', $cur_dis->name);
                 $q->add('education_id', $new_id);
                 $q->add('order_num', $cur_dis->order_num);
                 $q->add('is_optional', $cur_dis->is_optional);
                 $q->query();
                 $new_item_id = $q->get_id();
                 $q = new query(RUDE_DATABASE_TABLE_EDUCATION_ITEMS_VALUES);
                 $q->where('item_id', $cur_dis->id);
                 $q->query();
                 $all_item_val = $q->get_object_list();
                 foreach ($all_item_val as $cur_item_val) {
                     $q = new cquery(RUDE_DATABASE_TABLE_EDUCATION_ITEMS_VALUES_PREVIEW);
                     $q->add('value', $cur_item_val->value);
                     $q->add('item_id', $new_item_id);
                     $q->add('col_num', $cur_item_val->col_num);
                     $q->query();
                 }
             }
             $status = true;
             break;
         default:
             $status = false;
             break;
     }
     if (get('ajax')) {
         if ($status) {
             exit(RUDE_AJAX_OK);
         } else {
             exit(RUDE_AJAX_ERROR);
         }
     }
     return true;
 }
    public function main()
    {
        ?>
		<div id="main">
		<div id="reports-new">
		<div class="ui error form segment square-corners no-shadow">
		<div class="three fields">
			<div class="field">
				<label>Год набора</label>
				<input id="year" name="year" placeholder="Год набора" type="text">
			</div>

			<div class="field">
				<label>Срок обучения (лет)</label>
				<input id="duration" name="duration" placeholder="4" type="text" onchange="calendar.update();">
			</div>

			<div class="field">
				<label>ФИО ректора</label>
				<?php 
        $settings = settings::get_rector_value(template_session::get_user_id());
        $rector = $settings->value;
        ?>
				<input id="rector" name="rector" value="<?php 
        if (!empty($rector)) {
            echo $rector;
        }
        ?>
" placeholder="М.П. Батура" type="text" >
			</div>
		</div>

		<div class="field">
			<label>Регистрационный номер учебного плана</label>
			<input id="registration_number" name="registration_number" placeholder="2014.09.20/000" type="text" >
		</div>

		<div class="field">
			<div class="ui fluid selection dropdown">
				<div class="default text">Форма обучения</div>
				<i class="dropdown icon"></i>
				<input type="hidden" id="training_form_id" name="training_form_id">
				<div class="menu">
					<?php 
        $training_forms = training_forms::get();
        if ($training_forms) {
            foreach ($training_forms as $training_form) {
                ?>
							<div class="item" data-value="<?php 
                echo $training_form->id;
                ?>
"><?php 
                echo html::escape($training_form->name);
                ?>
</div>
						<?php 
            }
        }
        ?>
				</div>
			</div>
		</div>

		<div class="field">
			<div class="ui fluid selection dropdown">
				<div class="default text">Квалификация специалиста</div>
				<i class="dropdown icon"></i>
				<input type="hidden" id="qualification_id" name="qualification_id" >
				<div class="menu">
					<?php 
        $qualifications = qualifications::get();
        if ($qualifications) {
            foreach ($qualifications as $qualification) {
                ?>
							<div class="item" data-value="<?php 
                echo $qualification->id;
                ?>
"><?php 
                echo html::escape($qualification->name);
                ?>
</div>
						<?php 
            }
        }
        ?>
				</div>
			</div>
		</div>

		<div class="field">
			<div class="ui fluid selection dropdown">
				<div class="default text">Специальность</div>
				<i class="dropdown icon"></i>
				<input type="hidden" id="specialty_id" name="specialty_id">
				<div class="menu">
					<?php 
        $specialties = specialties::get();
        if ($specialties) {
            foreach ($specialties as $specialty) {
                ?>
							<div class="item" data-value="<?php 
                echo $specialty->id;
                ?>
"><?php 
                echo html::escape($specialty->name);
                ?>
</div>
						<?php 
            }
        }
        ?>
				</div>
			</div>
		</div>

		<div class="field">
			<div class="ui fluid selection dropdown">
				<div class="default text">Специализация</div>
				<i class="dropdown icon"></i>
				<input type="hidden" id="specialization_id" name="specialization_id" >
				<div class="menu">
					<?php 
        $specializations = specializations::get();
        if ($specializations) {
            foreach ($specializations as $specialization) {
                ?>
							<div class="item" data-value="<?php 
                echo $specialization->id;
                ?>
"><?php 
                echo html::escape($specialization->name);
                ?>
</div>
						<?php 
            }
        }
        ?>
				</div>
			</div>
		</div>

		<?php 
        //						$calendar = new ajax_calendar();
        //						$calendar->html();
        ?>

		<div class="ui green submit button small" onclick="save(0); return false;">Сохранить</div>
		<a href="#" target="_blank" id="button-preview" class="ui blue submit button small" onclick="save(1); return false;">Предпросмотр</a>
		<a href="#" target="_blank" id="button-popup" class="ui blue submit button small" onclick="calendar.popup(); return false;">Календарь</a>

		<div class="ui dimmer page hidden">
		<div id="calendar" class="ui modal large transition hidden">
		<i class="close icon"></i>

		<div class="header">
			Календарь
		</div>

		<div class="content">
		<table class="ui basic table">
		<tr>
			<th rowspan="3">к<br/>у<br/>р<br/>с<br/>ы</th>
			<th colspan="4">Сентябрь</th>
			<th></th>
			<th colspan="3">Октябрь</th>
			<th></th>
			<th colspan="4">Ноябрь</th>
			<th colspan="4">Декабрь</th>
			<th></th>
			<th colspan="3">Январь</th>
			<th></th>
			<th colspan="3">Февраль</th>
			<th></th>
			<th colspan="4">Март</th>
			<th></th>
			<th colspan="3">Апрель</th>
			<th></th>
			<th colspan="4">Май</th>
			<th colspan="4">Июнь</th>
			<th></th>
			<th colspan="3">Июль</th>
			<th></th>
			<th colspan="4">Август</th>
		</tr>
		<tr>
			<td>1</td>
			<td>8</td>
			<td>15</td>
			<td>22</td>
			<td>
				<div class="underline">29</div>
				09
			</td>
			<td>6</td>
			<td>13</td>
			<td>20</td>
			<td>
				<div class="underline">27</div>
				10
			</td>
			<td>3</td>
			<td>10</td>
			<td>17</td>
			<td>24</td>
			<td>1</td>
			<td>8</td>
			<td>15</td>
			<td>22</td>
			<td>
				<div class="underline">29</div>
				12
			</td>
			<td>5</td>
			<td>12</td>
			<td>19</td>
			<td>
				<div class="underline">26</div>
				01
			</td>
			<td>2</td>
			<td>9</td>
			<td>16</td>
			<td>
				<div class="underline">23</div>
				02
			</td>
			<td>2</td>
			<td>9</td>
			<td>16</td>
			<td>23</td>
			<td>
				<div class="underline">30</div>
				03
			</td>
			<td>6</td>
			<td>13</td>
			<td>20</td>
			<td>
				<div class="underline">27</div>
				04
			</td>
			<td>4</td>
			<td>11</td>
			<td>18</td>
			<td>25</td>
			<td>1</td>
			<td>8</td>
			<td>15</td>
			<td>22</td>
			<td>
				<div class="underline">29</div>
				06
			</td>
			<td>6</td>
			<td>13</td>
			<td>20</td>
			<td>
				<div class="underline">27</div>
				07
			</td>
			<td>3</td>
			<td>10</td>
			<td>17</td>
			<td>24</td>
		</tr>
		<tr>
			<td>7</td>
			<td>14</td>
			<td>21</td>
			<td>28</td>
			<td>
				<div class="underline">05</div>
				10
			</td>
			<td>12</td>
			<td>19</td>
			<td>26</td>
			<td>
				<div class="underline">02</div>
				11
			</td>
			<td>7</td>
			<td>16</td>
			<td>23</td>
			<td>30</td>
			<td>7</td>
			<td>14</td>
			<td>21</td>
			<td>28</td>
			<td>
				<div class="underline">04</div>
				01
			</td>
			<td>11</td>
			<td>18</td>
			<td>25</td>
			<td>
				<div class="underline">01</div>
				02
			</td>
			<td>8</td>
			<td>15</td>
			<td>22</td>
			<td>
				<div class="underline">01</div>
				03
			</td>
			<td>8</td>
			<td>15</td>
			<td>22</td>
			<td>29</td>
			<td>
				<div class="underline">05</div>
				04
			</td>
			<td>12</td>
			<td>19</td>
			<td>26</td>
			<td>
				<div class="underline">03</div>
				05
			</td>
			<td>10</td>
			<td>17</td>
			<td>24</td>
			<td>31</td>
			<td>7</td>
			<td>14</td>
			<td>21</td>
			<td>28</td>
			<td>
				<div class="underline">05</div>
				07
			</td>
			<td>12</td>
			<td>19</td>
			<td>26</td>
			<td>
				<div class="underline">02</div>
				08
			</td>
			<td>9</td>
			<td>16</td>
			<td>23</td>
			<td>31</td>
		</tr>

		<?php 
        for ($i = 1; $i <= 0; $i++) {
            ?>
<tr id="generated-<?php 
            echo $i;
            ?>
" class="generated"><td><?php 
            echo int::to_roman($i);
            ?>
</td><?php 
            for ($j = 1; $j < 53; $j++) {
                $val = '';
                ?>
					<td>
						<div class="ui form">
							<div class="inline field">
								<input class="<?php 
                echo $j;
                ?>
" type="text" maxlength="2" value="<?php 
                echo $val;
                ?>
">
							</div>
						</div>
					</td>
				<?php 
            }
            ?>
</tr><?php 
        }
        ?>
		</table>

		<br />

		<div class="ui icon buttons constructor">
			<div class="ui button" onclick="calendar_char = ''"><i class="align icon eraser"></i></div>

			<?php 
        $legend = calendar_legend::get();
        if ($legend) {
            foreach ($legend as $item) {
                ?>
						<div class="ui button constructor" title="<?php 
                echo $item->description;
                ?>
" onclick="calendar_char = '<?php 
                echo $item->legend_letter;
                ?>
'"><?php 
                echo $item->legend_letter;
                ?>
</div>
						<?php 
            }
        }
        ?>
		</div>

		<script>
			rude.semantic.init.buttons();


			var calendar_char = '';


			$(function () {
				mouse_selection();
			});

			function mouse_selection()
			{
				var isMouseDown = false;

				$('#calendar .content table.ui.basic td')
					.mousedown(function () {
						isMouseDown = true;

						$(this).addClass('highlighted');
						$(this).find('input').val(calendar_char);

						return false; // prevent text selection
					})
					.mouseover(function () {
						if (isMouseDown) {
							$(this).addClass('highlighted');
							$(this).find('input').val(calendar_char);
						}
					});

				$(document)
					.mouseup(function () {
						isMouseDown = false;
					});
			}
		</script>


		<a href="#" target="_blank" id="button-save" class="ui blue submit button small" onclick="calendar.save(0); $('#calendar .icon.close').click(); return false;">Сохранить</a>
		</div>
		</div>
		</div>

		<div style="display: none">
			<table>
				<tr id="calendar-hidden">
					<?php 
        for ($i = 1; $i < 53; $i++) {
            ?>
							<td>
								<div class="ui form">
									<div class="inline field">
										<input class="<?php 
            echo $i;
            ?>
" type="text" maxlength="2">
									</div>
								</div>
							</td>
							<?php 
        }
        ?>
				</tr>
			</table>
		</div>


		<script>
			function save(is_tmp)
			{
				var report = new Report();
				$.ajax(
					{
						url: '/?page=reports-new&task=add&ajax=true&is_tmp=' + is_tmp,

						data:
						{
							is_tmp:              is_tmp,

							year:                report.year,
							duration:            report.duration,
							rector:              report.rector,
							registration_number: report.registration_number,
							training_form_id:    report.training_form_id,
							qualification_id:    report.qualification_id,
							specialty_id:        report.specialty_id,
							specialization_id:   report.specialization_id
						},

						success: function (report_id)
						{
							console.log(report_id);

							if (report_id)
							{
								if (is_tmp)
								{
									calendar.save(1, report_id, true);
								}
								else
								{
									calendar.save(0, report_id, false);
									rude.redirect('/?page=reports-edit&report_id=' + report_id);
								}
							}
						}
					});
			}



			function Report()
			{
				this.year                = $('#year').val();
				this.duration            = $('#duration').val();
				this.rector              = $('#rector').val();
				this.registration_number = $('#registration_number').val();
				this.training_form_id    = $('#training_form_id').val();
				this.qualification_id    = $('#qualification_id').val();
				this.specialty_id        = $('#specialty_id').val();
				this.specialization_id   = $('#specialization_id').val();
			}

			var calendar =
			{

				reset: function()
				{
					$('#calendar .generated').remove();
				},

				update: function()
				{
					var duration = $('#duration').val();

					if (calendar.duration === null || calendar.duration != duration)
					{
						calendar.reset();

						var row = $('#calendar-hidden').html();

						for (var i = 1; i <= duration; i++)
						{
							$('#calendar table').append('<tr id="generated-' + i + '" class="generated"><td>' + rude.romanize(i) + '</td>' + row + '</tr>');
						}
					}

					calendar.duration = duration;

					mouse_selection();
				},

				popup: function()
				{
					if (calendar.duration === null)
					{
						calendar.update();
					}

					$('#calendar').modal('show').modal('cache sizes');

					setTimeout(function() {
						$('#calendar').modal('refresh');
					}, 750);
				},

				get: function()
				{
					var result = [];

					for (var i = 1; i <= $('#duration').val(); i++)
					{
						var selector = '#generated-' + i;

						if ($(selector).length)
						{
							var cols = $(selector + ' td').length;

							for (var j = 1; j < cols; j++)
							{
								if ($(selector + ' .' + j).val() !== '')
								{
									result.push([i, j, $(selector + ' .' + j).val()]);
								}
							}
						}
					}

					return result;
				},

				save: function(is_tmp, report_id, prewiew)
				{
					var data = calendar.get();





					$.ajax(
						{
							url: '/?page=calendar&task=save&ajax=true',

							type: 'POST',

							data:
							{
								is_tmp: is_tmp,

								data: data,
								report_id: report_id
							},

							success: function (data)
							{
								console.log(data);


								if (prewiew)
								{
									rude.open('/?page=reports-preview&is_tmp=1&report_id=' + report_id, true);
								}
							}
						});
				}
			}
		</script>
		</div>
		</div>
		</div>
	<?php 
    }
 public static function init()
 {
     template_session::logout();
 }
示例#11
0
 public static function init()
 {
     template_session::init();
     switch (get('page')) {
         case 'registration':
             ajax_registration::init();
             break;
         case 'authorization':
             ajax_authorization::init();
             break;
         case 'logout':
             ajax_logout::init();
             break;
         case 'calendar':
             ajax_calendar_items::init();
             break;
         case 'departments':
             $template = new template_departments();
             break;
         case 'faculties':
             $template = new template_faculties();
             break;
         case 'qualifications':
             $template = new template_qualifications();
             break;
         case 'specializations':
             $template = new template_specializations();
             break;
         case 'specialties':
             $template = new template_specialties();
             break;
         case 'users':
             $template = new template_users();
             break;
         case 'users-roles':
             $template = new template_users_roles();
             break;
         case 'calendar_legend':
             $template = new template_calendar_legend();
             break;
         case 'settings':
             $template = new template_settings();
             break;
         case 'directions':
             $template = new template_directions();
             break;
         case 'stats':
             $template = new template_stats();
             break;
         case 'reports':
             $template = new template_reports();
             break;
         case 'reports-new':
             $template = new template_reports_new();
             break;
         case 'reports-edit':
             $template = new template_reports_edit();
             break;
         case 'reports-preview':
             $template = new template_reports_preview();
             break;
         default:
             if (!url::is_homepage()) {
                 $template = new template_404();
             } else {
                 $template = new template_homepage();
             }
     }
     if (isset($template) and !get('ajax')) {
         $template->html();
     }
 }