<?php
class report_local_words extends c_report
{
 var $title='Локализация ЭСМО' ;
 var $view_by_space_filter=1 ;
 var $allow_org_ids=1 ;
 var $usl_select_org='' ;
 var $local_id=0 ;

 function setting($options=array())
    {   ?><div id="panel_filter">
                <form id="sky-form" class="sky-form"><input type="hidden" name="filter_dir" value="<?echo _CUR_REPORT_DIR?>">
                     <fieldset>
                         <div class="row" id="person_info">
                             <? $this->filter_section_input_text('name','Исходный вариант:',4) ;
                                $this->filter_section_input_text('name2','Перевод:',4) ;
                             ?>
                         </div>
                     </fieldset>
                     <div id="panel_buttons">
                         <input type="submit" class="button v2" cmd=aspmo_setting/local_word_add local_id="<?echo $this->local_id?>" value="Добавить">
                         <input type="submit" class="button v2" cmd="set_filter" value="Найти">
                     </div>
                 </form>
          </div><br>
        <?
     }

  function create_usl_select_obj($_params,&$options)
  {  $usl=array() ;
     $usl[]='clss=275' ;
     if ($this->local_id) $usl[]='parent='.$this->local_id ;
     if ($this->filter['name'])             $usl[]='obj_name like "'.$this->filter['name'].'%"' ;
     if ($this->filter['name2'])            $usl[]='obj_name_loc like "'.$this->filter['name2'].'%"' ;
     $usl_res=implode(' and ',$usl) ;
     //damp_array($usl,1,-1) ;
     return($usl_res) ;
  }

 function panel_info_filter()
 { $_str=array() ; $info=array() ; $title='' ;
   //damp_array($this->filter) ;
   if ($this->filter['name'])                            $info['Исходный вариант']='"'.$this->filter['name'].'"' ;
   if ($this->filter['name2'])                           $info['Перевод']='"'.$this->filter['name2'].'"' ;

   if (_sizeof($info)) foreach($info as $title=>$value) $_str[]=$title.': <strong>'.$value.'</strong>' ;
   if (_sizeof($_str)) $title='<p class=center>'.implode(' ',$_str).'</p>' ;
   return $title ;
 }


  function get_cnt_items($usl,$options=array())
  { $cnt=execSQL_value('select count(pkey)
                        from  obj_site_locals
                        where '.$usl,$options) ;
    return($cnt) ;
  }

  function get_items($usl,$options=array())
  { $limit=($options['limit'])? ' '.$options['limit']:'' ;
    $order=($this->filter['order'])? ' order by '.$this->filter['order']:' order by pkey desc' ;
 	$list_rec=execSQL('select *
                       from  obj_site_locals
                       where '.$usl.$order.$limit,$options) ;
    return($list_rec) ;
  }


    // шаблон - вывод ссылками без разделитея
    function print_template_HTML($list_recs,$options=array())
    { ?><div id="report_membes"><form><?

       ?><table class="basic full auto fz_small"><tr><th>ID</th><th>Исходный вариант</th><th>Перевод</th><th>Операция</th></tr><?
       if (_sizeof($list_recs)) foreach($list_recs as $rec)
       {?>
        <tr><td width="10%"><?echo $rec['pkey']?></td>
            <td width="40%"><input style="width:100%;" type="text" name=name[<?echo $rec['pkey']?>] value="<?echo htmlspecialchars($rec['obj_name'])?>"</td>
            <td width="40%"><input style="width:100%;" type="text" name=name2[<?echo $rec['pkey']?>] value="<?echo htmlspecialchars($rec['obj_name_loc'])?>"></td>
            <td><i class="fa fa-floppy-o v2" aria-hidden="true" cmd=aspmo_setting/local_word_save local_id="<?echo $this->local_id?>" word_id="<?echo $rec['pkey']?>" alt="Сохранить" title="Сохранить"></i></td>
         </tr>
     <?}?>
      </table></form><?
   ?></div><?
       // print_2x_arr($list_recs) ;
  }
}
?>
