0 Пользователей и 1 Гость просматривают эту тему.
  • 1 Ответов
  • 1075 Просмотров
*

artem9515

  • Новичок
  • 7
  • 0 / 0
Есть таблица заполненная данными бд, в ней чекбокс при нажатии на который должен поменяться status с 0 на 1, но почему-то не работает, Помогите люди добрые
Вот default.php

Код
<?php
/** @var $this ZapisyViewForm_For_Administr */
defined( '_JEXEC' ) or die; // No direct access


?>
<script src="/joomla/media/jui/js/jquery.js"></script>
<script src="/joomla/media/jui/js/jquery.min.js"></script>
<script src="/joomla/media/jui/js/jquery.tablesorter.js"></script>
<script src="/joomla/media/jui/js/jquery.tablesorter.widgets.js"></script>


<!-- Bootstrap stylesheet -->
<link rel="stylesheet" href="/joomla/media/jui/docs/css/bootstrap.min.css">

<!-- bootstrap widget theme -->
<link rel="stylesheet" href="/joomla/media/jui/css/theme.bootstrap.css">

<link rel="stylesheet" href="/joomla/media/jui/addons/pager/jquery.tablesorter.pager.css">
<script src="/joomla/media/jui/addons/pager/jquery.tablesorter.pager.js"></script>



<script id="js">
$(function() {

  // NOTE: $.tablesorter.theme.bootstrap is ALREADY INCLUDED in the jquery.tablesorter.widgets.js
  // file; it is included here to show how you can modify the default classes
  $.tablesorter.themes.bootstrap = {
    // these classes are added to the table. To see other table classes available,
    // look here: http://getbootstrap.com/css/#tables
    table        : 'table table-bordered table-striped',
    caption      : 'caption',
    // header class names
    header       : 'bootstrap-header', // give the header a gradient background (theme.bootstrap_2.css)
    sortNone     : '',
    sortAsc      : '',
    sortDesc     : '',
    active       : '', // applied when column is sorted
    hover        : '', // custom CSS required - a defined bootstrap style may not override other classes
    // icon class names
    icons        : '', // add "icon-white" to make them white; this icon class is added to the <i> in the header
    iconSortNone : 'bootstrap-icon-unsorted', // class name added to icon when column is not sorted
    iconSortAsc  : 'glyphicon glyphicon-chevron-up', // class name added to icon when column has ascending sort
    iconSortDesc : 'glyphicon glyphicon-chevron-down', // class name added to icon when column has descending sort
    filterRow    : '', // filter row class; use widgetOptions.filter_cssFilter for the input/select element
    footerRow    : '',
    footerCells  : '',
    even         : '', // even row zebra striping
    odd          : ''  // odd row zebra striping
  };

  // call the tablesorter plugin and apply the uitheme widget
  $("table").tablesorter({
    // this will apply the bootstrap theme if "uitheme" widget is included
    // the widgetOptions.uitheme is no longer required to be set
    theme : "bootstrap",

    widthFixed: true,

    headerTemplate : '{content} {icon}', // new in v2.7. Needed to add the bootstrap icon!

    // widget code contained in the jquery.tablesorter.widgets.js file
    // use the zebra stripe widget if you plan on hiding any rows (filter widget)
    widgets : [ "uitheme", "filter", "zebra" ],

    widgetOptions : {
      // using the default zebra striping class name, so it actually isn't included in the theme variable above
      // this is ONLY needed for bootstrap theming if you are using the filter widget, because rows are hidden
      zebra : ["even", "odd"],

      // reset filters button
      filter_reset : ".reset",

      // extra CSS class name (string or array) added to the filter element (input or select)
      filter_cssFilter: "form-control",

      // set the uitheme widget to use the bootstrap theme class names
      // this is no longer required, if theme is set
      // ,uitheme : "bootstrap"

    }
  })
  .tablesorterPager({

    // target the pager markup - see the HTML block below
    container: $(".ts-pager"),

    // target the pager page select dropdown - choose a page
    cssGoto  : ".pagenum",

    // remove rows from the table to speed up the sort of large tables.
    // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
    removeRows: false,

    // output string - default is '{page}/{totalPages}';
    // possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows}
    output: '{startRow} - {endRow} / {filteredRows} ({totalRows})'

  });

});
</script>



<form action="<?php echo JRoute::_( 'index.php?view=Form_For_Administr' )?>" method="post" class="form-validate">
<table class="table table-striped table-bordered table-condensed">
     <thead>
       <tr>
            <th></th>
           <th>ФИО</th>
           <th>Создано</th>
           <th>Ном.Полиса</th>
           <th>Телефон</th>
           <th>Ст</th>
       </tr>
     <thead>
     <tfoot>
       <tr>
        <th></th>
        <th>ФИО</th>
        <th>Создано</th>
        <th>Ном.Полиса</th>
        <th>Телефон</th>
        <th>Ст</th>
        </tr>
        <tr>
         <th colspan="6" class="ts-pager form-horizontal">
                <button type="button" class="btn first"><i class="icon-step-backward glyphicon glyphicon-step-backward"></i></button>
                <button type="button" class="btn prev"><i class="icon-arrow-left glyphicon glyphicon-backward"></i></button>
                <span class="pagedisplay"></span> <!-- this can be any element, including an input -->
                <button type="button" class="btn next"><i class="icon-arrow-right glyphicon glyphicon-forward"></i></button>
                <button type="button" class="btn last"><i class="icon-step-forward glyphicon glyphicon-step-forward"></i></button>
                <select class="pagesize input-mini" title="Select page size">
                  <option selected="selected" value="10">10</option>
                  <option value="20">20</option>
                  <option value="30">30</option>
                  <option value="40">40</option>
                </select>
                <select class="pagenum input-mini" title="Select page number"></select>
              </th>
        </tr>
      </tfoot>
        <tbody>
         <?php if ($this->rows): foreach ($this->rows as $i => $row):
          $checked = JHTML::_('grid.id', $i, $row->id);
          $link = 'index.php?option=com_zapisy&view=create' . $row->id;
         ?>
     <tr class="row<?php echo $i ; ?>">
         <td><div class="control-group form-inline">
                     <div class="control-label"><?php echo $this->form->getLabel( 'status' ); ?></div>
                     <div class="controls"><?php echo $this->form->getInput( 'status' ); ?></div>
                     </div></td>
         <td><?php echo $row->fio; ?></td>
         <td><?php echo $row->created; ?></td>
         <td><?php echo $row->nom_polis; ?></td>
         <td><?php echo $row->cont_tel; ?></td>
         <td><?php echo $row->status; ?></td>
     </tr>
     <?php  endforeach;  else: ?>
     <tr>
         <td colspan="15">Пациентов нет</td>
     <tr>
     <?php endif; ?>
    </tbody>
</table>

<input type="hidden" name="task" value="Form_For_Administr.save" />
    <input type="submit" value="Отправить" />
    <?php echo JHtml::_( 'form.token' ); ?>
</form>


XML

Код
<?xml version="1.0"?>
<form>
    <fieldset>
        <field name="status" type="checkbox" label="СтатусЯ" class="span3" default="0" value="1" />
    </fieldset>
</form>

Контроллер

Код
<?php
// No direct access
defined( '_JEXEC' ) or die;

/**
 * Controller
 * @author Artem Kuleshov
 */
class ZapisyControllerForm_For_Administr extends JControllerLegacy
{



public function edit()
{
        JRequest::setVar('view', 'create');
         $this->display();
}
}


И models

Код
<?php

// No direct access
defined( '_JEXEC' ) or die;

/**
 * Model to see the current entries
 * @author Artem Kuleshov
 */
class ZapisyModelForm_For_Administr extends JModelList
{
private $_teach;
      function __construct()
      {
            parent::__construct();
      }

      public function getForm( $data = array(), $loadData = true )
       {
       $form = $this->loadForm( '', 'form_for_administr', array( 'control' => 'jform', 'load_data' => $loadData ) );
       if ( empty( $form ) ) {
       return false;
       }
       return $form;
       }

      public function getTeach()
      {
           if (empty($this->_teach))
                {
            $query      = 'SELECT * ' . ' FROM ' . '#__tablic_clienta' ;
            $this->_db->setQuery($query);
            $this->_teach = $this->_db->loadObjectList();
                }

            return $this->_teach;
      }



       /**
       * Method of loading data to form
       * @return Object
       */
//       protected function loadFormData()
//       {
//       $data = JFactory::getApplication()->getUserState( 'com_zapisy.edit.form_for_administr.data', array() );
//       if ( empty( $data ) ) {
//       $data = $this->getItem();
//       }
//       return $data;
//       }


      public function save( $data )
       {
       return parent::save( $data );
       }


}


« Последнее редактирование: 18.10.2015, 23:12:46 от artem9515 »
*

White_Tiger

  • Захожу иногда
  • 88
  • 3 / 0
Re: Не вносятся изменения в бд
« Ответ #1 : 20.10.2015, 09:01:15 »
Ох, сударь, не в обиду будет сказано, но Вы бы выбросили лишний код (с форума в смысле выбросили). Выглядит очень удручающе и его кол-во отбивает напрочь желание всматриваться.
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

К2 не сохраняет изменения

Автор baren

Ответов: 3
Просмотров: 3248
Последний ответ 06.07.2021, 20:45:50
от draff
Не сохраняются изменения при работе компонента

Автор polezniy

Ответов: 16
Просмотров: 721
Последний ответ 03.07.2021, 01:32:13
от polezniy
После изменения файла template.css не отображаются изменения в браузерах

Автор SaXalIneC

Ответов: 2
Просмотров: 487
Последний ответ 06.04.2021, 08:10:07
от rsn
Ошибка после изменения версии PHP - call to undefined function

Автор lexus26

Ответов: 1
Просмотров: 536
Последний ответ 28.02.2021, 15:18:13
от NewUsers
Изменения размера изображения в модуле

Автор Andru

Ответов: 7
Просмотров: 845
Последний ответ 23.08.2020, 15:54:03
от Andru