public function calendar() { ?> <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> <?php $items = null; if (calendar_items::is_exists($this->report->id)) { $items = calendar_items::get($this->report->id); } $legend = calendar_legend::get(); if ($legend) { foreach ($legend as $symbol) { ?> <th rowspan="3"><?php echo $symbol->legend_letter; ?> </th><?php } } ?> </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 if ($this->report->duration > 0) { for ($i = 1; $i <= $this->report->duration; $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 = ''; if ($items) { foreach ($items as $item) { if ($item->year == $i and $item->column == $j) { $val = $item->value; break; } } } ?> <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 } if ($legend) { foreach ($legend as $symbol) { $pointer = urlencode($symbol->legend_letter); if (!$pointer) { $pointer = 'null'; } ?> <td class="legend" id="legend-<?php echo $i; ?> -<?php echo $pointer; ?> "></td><?php } ?> <td class="legend total" id="legend-<?php echo $i; ?> -total"></td><?php } ?> </tr> <?php } } ?> <tr id="generated-bottom" class="no-bottom"> <td colspan="53" class="no-border"></td> <?php if ($legend) { foreach ($legend as $symbol) { $character = urlencode($symbol->legend_letter); if (!$character) { $character = 'null'; } ?> <td class="total" id="total-<?php echo $character; ?> "></td><?php } } ?> </tr> </table> <br /> <div id="calendar-buttons-tools" class="ui icon buttons constructor"> <?php if ($legend) { foreach ($legend as $item) { ?> <div class="ui button constructor" title="<?php echo $item->description; ?> " onclick="calendar_char = '<?php echo $item->legend_letter; ?> '; $('#calendar-buttons-eraser .button').removeClass('active')"><?php echo $item->legend_letter; ?> </div> <?php } } ?> </div> <div id="calendar-buttons-eraser" class="ui icon buttons constructor"> <div class="ui button" onclick="calendar_char = ''; $('#calendar-buttons-tools .button.constructor').removeClass('active');"><i class="align icon eraser"></i></div> </div> <script> rude.semantic.init.buttons(); var calendar_char = ''; $(function () { mouse_selection(); }); $(function () { calendar_recount(); }); function symbols() { return [<?php if ($legend) { $array = null; foreach ($legend as $symbol) { $character = urlencode($symbol->legend_letter); if (!$character) { $character = 'null'; } $array[] = "'" . $character . "'"; } echo implode(',', $array); } ?> ]; } function calendar_recount() { var items = calendar.get(); var duration = $('#duration').val(); var counts = {}; for (var i = 1; i <= duration; i++) { counts[i] = {}; } for (i = 1; i <= duration; i++) { var characters = symbols(); for (var k = 0; k < characters.length; k++) { counts[i][characters[k]] = 0; } counts['total'] = {}; for (k = 0; k < characters.length; k++) { counts['total'][characters[k]] = 0; } counts['total']['null'] = 0; } for (var j = 0; j < items.length; j++) { var item = items[j]; var item_year = item[0]; var item_char = encodeURIComponent(item[2]); if (typeof item[2] == 'undefined') { continue; } if (typeof counts[item_year][item_char] == 'undefined') { counts[item_year][item_char] = 0; } counts[item_year][item_char] += 1; counts['total'][item_char] += 1; } if (counts) { for (i = 1; i <= duration; i++) { var year = counts[i]; var empty = 52; for (var property in year) { if (year.hasOwnProperty(property)) { $('[id="legend-' + i + '-' + property + '"]').html(format(year[property])); empty -= year[property]; } } $('[id="legend-' + i + '-null"]').html(format(empty)); $('[id="legend-' + i + '-total"]').html(format(52 - empty)); counts['total']['null'] += empty; } for (var char in counts['total']) { if (counts['total'].hasOwnProperty(char)) { $('[id="total-' + char + '"]').html(format(counts['total'][char])); } } // $('[id="legend-' + i + '-null"]').html(format(empty)); } } function format(val) { if (val == 0) { return '<span class="empty">0</span>'; } return val; } 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); calendar_recount(); return false; // prevent text selection }) .mouseover(function () { if (isMouseDown) { $(this).addClass('highlighted'); $(this).find('input').val(calendar_char); calendar_recount(); } }); $(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(); dimmer.show(); $.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, study_practice: report.study_practice, manufact_practice: report.manufact_practice, grad_work: report.grad_work, gos_exam: report.gos_exam }, success: function (report_id) { $('.tip li').each(function(){ var item_id= $(this).data('id'); var item_order= $(this).data('order'); var optional = 0; if($(this).find('.checkbox').find('input').prop('checked')){ optional = 1; } $.ajax( { url: '/?page=reports-edit&is_tmp=1&optional='+optional+'&item_id='+item_id+'&item_order='+item_order+'&report_id='+report_id+'&task=update_education_item&ajax=true', success: function (data) { console.log(data); } }); }); $('.disciplines').each(function(){ var dis_id= $(this).data('id'); $.ajax( { url: '/?page=reports-edit&is_tmp=1&dis_id='+dis_id+'&report_id='+report_id+'&task=copy_education&ajax=true', success: function (data) { console.log(data); } }); }); console.log(report_id); if (report_id) { if (is_tmp) { calendar.save(1, report_id, true); } else { rude.open('/?page=reports-edit&report_id=' + report_id); } } setTimeout(function() { dimmer.hide(); }, 1750); } }); } function update() { var report_id = '<?php echo $this->report->id; ?> '; var report = new Report(); $('.disciplines').each(function(){ var dis_id= $(this).data('id'); $.ajax( { url: '/?page=reports-edit&dis_id='+dis_id+'&report_id='+report_id+'&task=update_education&ajax=true', success: function (data) { console.log(data); } }); }); $('.tip li').each(function(){ var item_id= $(this).data('id'); var item_order= $(this).data('order'); var optional = 0; if($(this).find('.checkbox').find('input').prop('checked')){ optional = 1; } $.ajax( { url: '/?page=reports-edit&tmp=0&optional='+optional+'&item_id='+item_id+'&item_order='+item_order+'&report_id='+report_id+'&task=update_education_item&ajax=true', success: function (data) { console.log(data); } }); }); $.ajax( { url: '/?page=reports-edit&task=update&ajax=true', data: { report_id: report_id, 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, study_practice: report.study_practice, manufact_practice: report.manufact_practice, grad_work: report.grad_work, gos_exam: report.gos_exam }, success: function (data) { console.log(data); } }); } 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(); this.study_practice = $('#study_practice').val(); this.manufact_practice = $('#manufact_practice').val(); this.grad_work = $('#grad_work').val(); this.gos_exam = $('#gos_exam').val(); } var calendar = { duration: <?php if ($this->report->id and calendar_items::is_exists($this->report->id)) { echo $this->report->id; } else { echo 'null'; } ?> , 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++) { var advanced = ''; var characters = symbols(); for (var j = 0; j < characters.length; j++) { advanced += '<td class="legend" id="legend-' + i + '-' + characters[j] + '"></td>'; } advanced += '<td class="legend total" id="legend-' + i + '-total"></td>'; $('#calendar table').append('<tr id="generated-' + i + '" class="generated"><td>' + rude.romanize(i) + '</td>' + row + advanced + '</tr>'); } var advanced_row = ''; for (j = 0; j < symbols().length; j++) { advanced_row += '<td class="total" id="total-' + symbols()[j] + '"></td>'; } if ($('#generated-bottom').length) { $('#generated-bottom').remove(); } $('#calendar table').append('<tr id="generated-bottom" class="no-bottom"><td colspan="53" class="no-border">' + advanced_row + '</td>'); } calendar.duration = duration; mouse_selection(); calendar_recount(); }, popup: function() { if ($('#duration').val() == 0) { alert('Пожалуйста, укажите вначале срок обучения'); return; } if (calendar.duration === null) { calendar.update(); } $('#calendar').modal('show').modal('cache sizes'); setTimeout(function() { $('#calendar').modal('refresh'); }, 750); }, get: function() { var result = []; var duration = $('#duration').val(); for (var i = 1; i <= duration; 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(); if (is_tmp) { var report_id = report_id; } else { var report_id = <?php echo $this->report->id; ?> ; } $.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> <?php }
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 head() { ?> <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> <?php $legend = calendar_legend::get(); if ($legend) { foreach ($legend as $item) { ?> <th rowspan="3" class="total"><?php echo string::to_capital($item->description); ?> </th> <?php } } ?> <th rowspan="3" class="total">Всего</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 }
public function main() { ?> <div id="main"> <?php $calendar_legends = calendar_legend::get(); ?> <table class="ui table segment square-corners celled"> <thead> <tr class="header"> <th class="numeric">#</th> <th>Описание</th> <th>Символ</th> <th colspan="2" class="right icon-add"><i class="icon add sign pointer" title="Добавить" onclick="$('#add_modal').modal('show');"></i></th> </tr> </thead> <tbody> <?php foreach ($calendar_legends as $calendar_legend) { ?> <tr id="calendar_legend-<?php echo $calendar_legend->id; ?> "> <td class="small numeric"><?php echo $calendar_legend->id; ?> </td> <td><?php echo $calendar_legend->legend_letter; ?> </td> <td><?php echo $calendar_legend->description; ?> </td> <td class="icon first no-border"> <a href="#" onclick="$('#edit_modal').modal('show'); $('.id').val('<?php echo $calendar_legend->id; ?> '); $('.editlegend_letter').val('<?php echo $calendar_legend->legend_letter; ?> '); $('.editdescription').val('<?php echo $calendar_legend->description; ?> ');"> <i class="icon edit" title="Редактировать"></i> </a> </td> <td class="icon last no-border"> <a href="#" onclick="$.post('<?php echo template_url::ajax('calendar_legend', 'remove', $calendar_legend->id); ?> ').done(function(answer) { answer_removed(answer, <?php echo $calendar_legend->id; ?> ); }); return false;"> <i class="icon remove circle" title="Удалить"></i> </a> </td> </tr> <?php } ?> </tbody> </table> </div> <script> function answer_removed(answer, calendar_legend_id) { console.log(answer); switch(answer) { case '<?php echo RUDE_AJAX_ERROR; ?> ': break; case '<?php echo RUDE_AJAX_OK; ?> ': console.log(this); $('#calendar_legend-' + calendar_legend_id).fadeOut('slow'); break; case '<?php echo RUDE_AJAX_ACCESS_VIOLATION; ?> ': $('#access-violation').modal('show'); break; default: break; } return false; } </script> <div id="add_modal" class="ui modal"> <i class="close icon"></i> <div class="header"> Добавить условное обозначение </div> <div class="content"> <div class="ui form segment"> <div class="field"> <label for="legend_letter">Символ условного обозначения</label> <div class="ui left labeled input"> <input maxlength="2" class="legend_letter" name="legend_letter" type="text" placeholder="Символ условного обозначения"> <div class="ui corner label"> <i class="icon asterisk"></i> </div> </div> </div> <div class="field"> <label for="description">Описание условного обозначения</label> <div class="ui left labeled input"> <input class="description" name="description" type="text" placeholder="Описание условного обозначения"> <div class="ui corner label"> <i class="icon asterisk"></i> </div> </div> </div> <div class="ui error message"> <div class="header">Найдены ошибки при заполнении формы</div> </div> <div class="ui blue submit button" value="add">Добавить</div> </div> </div> </div> <script> $('#add_modal .ui.form') .form({ legend_letter: { identifier : 'legend_letter', rules: [ { type : 'empty', prompt : 'Пожалуйста, укажите символ условного обозначения.' } ] }, description: { identifier : 'description', rules: [ { type : 'empty', prompt : 'Пожалуйста, укажите описание условного обозначения.' } ] } }, { onSuccess: function() { var legend_letter = $('.legend_letter').val(); var description = $('.description').val(); $.post('/?page=calendar_legend&task=add&legend_letter='+legend_letter+'&description='+description+'&ajax=true') .done(function() {/*$('#add_modal').modal('hide'); rude.redirect('/?page=calendar_legend');*/ }); return false; } }) ; </script> <div id="edit_modal" class="ui modal"> <i class="close icon"></i> <div class="header"> Редактировать условное обозначение </div> <div class="content"> <div class="ui form segment"> <div class="field"> <label for="editlegend_letter">Символ условного обозначения</label> <div class="ui left labeled input"> <input maxlength="2" class="editlegend_letter" name="editlegend_letter" type="text" placeholder="Символ условного обозначения"> <div class="ui corner label"> <i class="icon asterisk"></i> </div> </div> </div> <div class="field"> <label for="editdescription">Описание условного обозначения</label> <div class="ui left labeled input"> <input class="editdescription" name="editdescription" type="text" placeholder="Описание условного обозначения"> <div class="ui corner label"> <i class="icon asterisk"></i> </div> </div> </div> <div class="field" hidden> <label for="id">id</label> <div class="ui left labeled input"> <input class="id" name="id" type="text" placeholder="id"> <div class="ui corner label"> <i class="icon asterisk"></i> </div> </div> </div> <div class="ui error message"> <div class="header">Найдены ошибки при заполнении формы</div> </div> <div class="ui blue submit button" value="edit">Изменить</div> </div> </div> </div> <script> $('#edit_modal .ui.form') .form({ editlegend_letter: { identifier : 'editlegend_letter', rules: [ { type : 'empty', prompt : 'Пожалуйста, укажите символ условного обозначения.' } ] }, editdescription: { identifier : 'editdescription', rules: [ { type : 'empty', prompt : 'Пожалуйста, укажите описание условного обозначения.' } ] } }, { onSuccess: function() { var editlegend_letter = $('.editlegend_letter').val(); var editdescription = $('.editdescription').val(); var id = $('.id').val(); $.post('/?page=calendar_legend&task=edit&id='+id+'&legend_letter='+editlegend_letter+'&description='+editdescription+'&ajax=true') .done(function() { $('#edit_modal').modal('hide'); rude.redirect('/?page=calendar_legend'); }); return false; } }) ; </script> <?php }