<?php
class report_health extends c_report
{
 var $title='Отчет по показателям состояния здоровья' ;
 var $filter=array() ;
 public $use_fusioncharts=1 ;
 var $PDF_master='TCPDF' ;  // короткие отчеты выгружвать через обычный  PDF

 function setting()
   {
     $data_info=execSQL_van('select min(c_data) as min_data,max(c_data) as max_data from obj_site_mo_session') ;
      // damp_array($data_info) ;
     $t=$data_info['min_data'] ;
     while($t<$data_info['max_data'])
     {   $ts=getdate($t) ;
         $cur_month=mktime(0,0,0,$ts['mon'],1,$ts['year']) ;
         $arr[$cur_month]=get_month_year($cur_month,'month year') ;
         $t=mktime(0,0,0,$ts['mon']+1,1,$ts['year']) ;
     }



        $data_info=execSQL_van('select min(c_data) as min_data,max(c_data) as max_data from obj_site_mo_session') ;
        $t=$data_info['min_data'] ;
	if ($data_info['max_data']>$data_info['min_data']) while($t<$data_info['max_data'])
         {   $ts=getdate($t) ;
            $cur_month=mktime(0,0,0,$ts['mon'],1,$ts['year']) ;
             $arr_from[$cur_month]=get_month_year($cur_month,'month year') ;
            $cur_month=mktime(0,0,0,$ts['mon']+1,1,$ts['year'])-1 ;
            $arr_to[$cur_month]=get_month_year($cur_month,'month year') ;
    	    $t=mktime(0,0,0,$ts['mon']+1,1,$ts['year']) ;
        }

      //damp_array($this->filter) ;
       //$this->filter['data_from']=date('d.m.Y',));
     //if (!isset($this->filter['min_mo']))  $this->filter['min_mo']=10 ;
     //if (!isset($this->filter['min_proc']))  $this->filter['min_proc']=70 ;

     ?><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">
                             <section class="col col-4">
                                 <label class="label">Подразделениe:</label>
                                 <label class="select">
                                      <select name="filter[dep_id]"><option value="0">Все</option>
                                        <? echo PERSONAL()->get_select_option(1,$this->filter['dep_id']) ;?>
                                     </select>
                                 </label>
                             </section>
                             <?$arr_groups=execSQL_row('select pkey,obj_name,clss from obj_site_account where clss=206')?>
                             <section class="col col-2">
                                 <label class="label">Группа:</label>
                                 <label class="select">
                                     <select name="filter[group_id]"><option value="0">Все</option><?
                                       if (_sizeof($arr_groups)) foreach($arr_groups as $id=>$name) {?><option value="<?echo $id?>" <?if($this->filter['group_id']==$id) echo 'selected'?>><?echo $name?></option><?}?>
                                     </select>
                                 </label>
                             </section>
                             <section class="col col-6">
                                 <label class="label">Должность</label>
                                 <? // если определены временные рамки - показывам делаем выборку по должностям, которые есть в этих рамках
                                                                         if (isset($this->filter['month_from']) and $this->filter['month_to'])
                                                                         {  $works_ids=execSQL_row('select distinct(working),1 from '.ESMO()->view_mo_session.' where c_data>='.$this->filter['month_from'].' and c_data<='.$this->filter['month_to']) ;
                                                                         }
                                 ?>

                                 <label class="select">
                                     <select name="filter[working][]" class="js-basic-multiple js-states form-control" multiple="multiple"><option></option>
                                        <?
                                            foreach(_IL('IL_works')->recs as $rec) if (!_sizeof($works_ids) or isset($works_ids[$rec['id']])) {?><option value="<?echo $rec['id']?>" <?if (isset($this->filter['working'][$rec['id']])) echo 'selected'?>><?echo $rec['obj_name']?></option><?}

                                         ?>
                                     </select>
                                 </label>
                             </section>

                             </div>
                             <div class="row">

                             <section class="col col-2">
                                 <label class="label">Тип контроля:</label>
                                 <label class="select">
                                     <select name="filter[tk]"><option value="0">Все</option><?
                                       if (_sizeof($_SESSION['ARR_mo_tk_type'])) foreach($_SESSION['ARR_mo_tk_type'] as $id=>$name) {?><option value="<?echo $id+1?>" <?if($this->filter['tk']==($id+1)) echo 'selected'?>><?echo $name?></option><?}?>
                                     </select>
                                 </label>
                             </section>

                             <section class="col col-2">
                                 <label class="label">С, месяц:</label>
                                 <label class="select">
                                     <select name="filter[time_from]">
                                     <?foreach($arr_from as $t=>$month){?><option value="<?echo $t?>" <?if ($this->filter['time_from']==$t) echo 'selected'?>><?echo $month?></option><?}?>
                                     </select>
                                 </label>
                             </section>
                             <section class="col col-2">
                                 <label class="label">По, месяц</label>
                                 <label class="select">
                                     <select name="filter[time_to]">
                                     <?foreach($arr_to as $t=>$month){?><option value="<?echo $t?>" <?if ($this->filter['time_to']==$t) echo 'selected' ?>><?echo $month?></option><?}?>
                                     </select>
                                 </label>
                             </section>
                             <section class="col col-2">
                                 <label class="label">Минимальное число МО:</label>
                                 <label class="input"><input type="text" name="filter[min_mo]" value="<?echo $this->filter['min_mo']?>"></label>
                             </section>
                             <section class="col col-2">
                                 <label class="label">Пороговый процент:</label>
                                 <label class="input"><input type="text" name="filter[min_proc]" value="<?echo $this->filter['min_proc']?>"></label>
                             </section>
                         </div>
                     </fieldset>
                     <?$this->panel_buttons();?>
                 </form>
         </div>
     <?
   }

 function setting_small()
   { ?><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">
                             <section class="col col-4">
                                 <label class="label">Организация</label>
                                 <label class="select">
                                     <select name="filter[org_ids][]" style="width: 100%" class="js-basic-multiple js-states form-control" multiple="multiple">
                                         <? $list_org=PERSONAL()->get_list_personal_section() ;
                                            // 6524 - ID тестовой группы
                                            foreach($list_org as $rec) if ($rec['pkey']!=6524) {?><option value="<?echo $rec['pkey']?>" <?if (isset($this->filter['org_ids'][$rec['pkey']])) echo 'selected'?>><?echo $rec['obj_name']?></option><?}?>
                                     </select>
                                 </label>
                             </section>
                             <section class="col col-2 buttons"><?$this->panel_button_apply();?></section>
                         </div>
                     </fieldset>

                 </form>
         </div>
     <?
   }

    function panel_info_filter()
    { $_str=array() ; $info=array() ; $title='' ;
      if ($this->filter['time_from'])                       $info['с']=date('d.m.Y H:i',$this->filter['time_from']) ;
      if ($this->filter['time_to'])                         $info['по']=date('d.m.Y H:i',$this->filter['time_to']) ;
      if ($this->filter['month_from'])                       $info['с']=date('d.m.Y H:i',$this->filter['month_from']) ;
      if ($this->filter['month_to'])                         $info['по']=date('d.m.Y H:i',$this->filter['month_to']) ;
      //if ($this->filter['time_int'])                        $info['временной интрервал']=$this->time_int[$this->filter['time_int']] ;
      if ($this->filter['group_id'])                        $info['Группа терминалов']=ACCOUNTS()->get_member_name_by_id($this->filter['group_id'])  ;
      if ($this->filter['org_id'])                          $info['Организация']=PERSONAL()->get_name_by_id($this->filter['org_id']) ;
      if ($this->filter['org_ids'])
      {   $arr_names=execSQL_line('select obj_name from obj_site_personals where pkey in ('.implode(',',array_keys($this->filter['org_ids'])).')') ;
          $info['Организация']=implode(', ',$arr_names)  ;
      }
      if ($this->filter['group_id'])                        $info['Группа']=ACCOUNTS()->get_member_name_by_id($this->filter['group_id'])  ;
      if ($this->filter['dep_id'])                          $info['Подразделение']=PERSONAL()->get_full_dep_name_by_dep_id($this->filter['dep_id'])  ;
      if ($this->filter['tk'])                              $info['Тип контроля']=$_SESSION['ARR_mo_tk_type'][$this->filter['tk']-1]  ;
      if ($this->filter['min_mo'])                          $info['Минимальное число МО']=$this->filter['min_mo']  ;
      if ($this->filter['min_proc'])                        $info['Порог']=$this->filter['min_proc'].' %'  ;
      if (_sizeof($info)) foreach($info as $title=>$value)   if (is_array($value)) $_str[]=$title.': <strong>'.implode(',',$value).'</strong>' ; else $_str[]=$title.': <strong>'.$value.'</strong>' ;
      if (_sizeof($_str)) $title='<p class=center>'.implode(' ',$_str).'</p>' ;
      return $title ;
    }

    function HTML_report_body($options=array())
    {   $rules=array() ;
        //$rules['opt']=array('s_min'=>0,  's_max'=>120,'title'=>'Оптимальное АД<br>ниже 120') ;
        //$rules['norm']=array('s_min'=>120,'s_max'=>130,'title'=>'Нормальное АД<br>120-129') ;
        //$rules['v_norm']=array('s_min'=>130,'s_max'=>140,'title'=>'Высокое нормальное АД<br>130–139') ;
        $rules['ag1']=array('s_min'=>140,'s_max'=>160,'title'=>'АГ I степени тяжести<br>140–159') ;
        $rules['ag2']=array('s_min'=>160,'s_max'=>179,'title'=>'АГ II степени тяжести<br>160–179') ;
        $rules['ag3']=array('s_min'=>180,'s_max'=>10000,'title'=>'АГ III степени тяжести<br>180 и выше') ;

        //damp_array($this->filter,1,-1) ;

        $data_info=execSQL_van('select min(c_data) as min_data,max(c_data) as max_data from obj_site_mo_session') ;

        if (!$this->filter['month_from'] and $this->filter['time_from']) $this->filter['month_from']=$this->filter['time_from'] ;
        if (!$this->filter['month_to'] and $this->filter['time_to']) $this->filter['month_to']=$this->filter['time_to'] ;

        if (!$this->filter['month_from'])
        { $ts=getdate($data_info['min_data']) ;
          $this->filter['month_from']=mktime(0,0,0,$ts['mon'],1,$ts['year']) ;;
        }

        if (!$this->filter['month_to'])
        { $ts=getdate($data_info['max_data']) ;
          $this->filter['month_to']=mktime(0,0,0,$ts['mon']+1,1,$ts['year'])-1 ;;
        }

         $table=array() ;  $arr_members_source=array() ;
         $t=$this->filter['month_from'] ;
         while($t<=$this->filter['month_to'])
         {   $ts=getdate($t) ;   $t1=$t ;
             $cur_month=mktime(0,0,0,$ts['mon'],1,$ts['year']) ;
             $arr_month[$cur_month]=get_month_year($cur_month,'month year') ;
             $t=mktime(0,0,0,$ts['mon']+1,1,$ts['year']) ; $t2=$t-1;


             //$stats_sd=execSQL('select _org_id,count(distinct(member_id)) from view_mo_session where hand_check_user_id is null and res_s=1 and res_d=1 and terminal_id>0 and c_data>='.strtotime($options['data_from']).' and c_data<='.strtotime($options['data_to']).' group by _org_id',2) ;


             //damp_array($this->filter) ;

            $options=array() ;
            $options['time_from']=$t1 ;
            $options['time_to']=$t2 ;
            //$options['status']='2,3' ;
            //$options['use_usl']='(hand_check_user_id is null or hand_check_user_id=0) and res_s=1 and res_d=1 and terminal_id>0' ;
            $options['use_usl']='personal_id>0 and terminal_id>0' ;
            if (_sizeof($this->filter['working'])) $options['use_usl'].=' and working in ('.implode(',',array_keys($this->filter['working'])).')' ;
            if ($this->filter['org'])     $options['use_usl'].=' and _org_id='.$this->filter['org'] ;
            if ($this->filter['dep_id'])     $options['dep_id']=$this->filter['dep_id'] ;
            if ($this->filter['org_id'])     $options['use_usl'].=' and _org_id='.$this->filter['org_id'] ;
            if ($this->filter['org_ids'])     $options['use_usl'].=' and _org_id in ('.implode(',',array_keys($this->filter['org_ids'])).')' ;
            if ($this->filter['group_id'])  $options['group_id']=$this->filter['group_id'] ;
            $options['order']='pkey' ;
            $options['fields']='pkey,c_data,status,systolic,diastolic,res_s,res_d,member_id,personal_id,personal_name,age' ;
            $options['no_public_info']=1 ;
            //$options['debug']=1 ;
            $options['view_name']='view_mo_session22' ;
            //damp_array($options,1,-1) ;
            list($recs_mo_sess,$stats)=ESMO()->get_mo_recs($options) ;
            //echo _sizeof($recs_mo_sess) ;

            //$usl_select_mo='model>0 ' ;
            $usl_select_mo='pkey>1' ;
            if ($this->filter['working']) $usl_select_mo.=' and working in ('.implode(',',array_keys($this->filter['working'])).')' ;
            if ($this->filter['org'])     $usl_select_mo.=' and _org_id='.$this->filter['org'] ;
            if ($this->filter['dep_id'])
             { $cur_level=execSQL_value('select level from obj_site_personals where pkey='.$this->filter['dep_id']) ;
                 $usl_select_mo.=' and personal_parent'.$cur_level.'='.$this->filter['dep_id'] ;
             }

            // не выводится на экран
            //$stats_cnt_mo=execSQL_value('select count(pkey) from view_mo_session where '.$usl_select_mo.' and c_data>='.$t1.' and c_data<='.$t2.' ') ;

            $usl_select_mo='status in (2,3)' ;
            if ($this->filter['working']) $usl_select_mo.=' and working in ('.implode(',',array_keys($this->filter['working'])).')' ;
            if ($this->filter['org'])     $usl_select_mo.=' and _org_id='.$this->filter['org'] ;
            if ($this->filter['dep_id'])
              { $cur_level=execSQL_value('select level from obj_site_personals where pkey='.$this->filter['dep_id']) ;
                  $usl_select_mo.=' and personal_parent'.$cur_level.'='.$this->filter['dep_id'] ;
              }

            //$stats_cnt_mo_sess=execSQL_value('select count(pkey) from view_mo_session where '.$usl_select_mo.' and c_data>='.$t1.' and c_data<='.$t2.' ') ;
            $stats_cnt_mo_sess=execSQL_value('select count(pkey) from view_mo_session22 where '.$usl_select_mo.' and c_data>='.$t1.' and c_data<='.$t2.' ') ;

            $result_ag=array() ;  $result_age=array() ;  $result_s=array() ; $result_d=array() ; $result_s_sr=array() ; $result_d_sr=array() ;

            $arr_members_source_prev_ids=array_keys($arr_members_source) ; $arr_members_source=array() ;
            if (_sizeof($recs_mo_sess)) foreach($recs_mo_sess as $rec_mo) $arr_members_source[$rec_mo['member_id']]++ ;
            $arr_members_source_cur_ids=array_keys($arr_members_source) ;


            //echo 'Всего человек: '._sizeof($arr_members_source).'<br>' ;

             // считаем средний возраст, тех, кто остался в списке
            if (_sizeof($recs_mo_sess)) foreach($recs_mo_sess as $rec_mo) $result_age[$rec_mo['member_id']]=$rec_mo['age'] ;

            // считаем среднее давление сотрудеников
            if (_sizeof($recs_mo_sess)) foreach($recs_mo_sess as $rec_mo)
            { $result_s[$rec_mo['member_id']][]=$rec_mo['systolic'] ;
              $result_d[$rec_mo['member_id']][]=$rec_mo['diastolic'] ;
            }

            if (_sizeof($result_s)) foreach($result_s as $member_id=>$arr_s)  $result_s_sr[$member_id]=round(array_sum($arr_s)/_sizeof($arr_s),2) ;
            if (_sizeof($result_d)) foreach($result_d as $member_id=>$arr_d)  $result_d_sr[$member_id]=round(array_sum($arr_d)/_sizeof($arr_d),2) ;

            // удаляем из списка МО, которые менее N раз в месяц
            //echo 'удаляем из списка сотрудников тех, которые менее N раз в месяц проходили МО<br>' ;
            $arr_members=$arr_members_source ;
            foreach($arr_members as $member_id=>$cnt_mo) if ($cnt_mo<$this->filter['min_mo']) unset($arr_members[$member_id]) ;

            //echo 'Всего человек после минимального числа МО: '._sizeof($arr_members).'<br>' ;

            //echo 'Считаем число попаданий в группы АГ<br>' ;
            if (_sizeof($recs_mo_sess)) foreach($recs_mo_sess as $rec_mo) if (isset($arr_members[$rec_mo['member_id']]))
            { $a=0 ;
              // проверяем попадание давления в группу
              if (_sizeof($rules)) foreach($rules as $id=>$params)
              {
                  if ($rec_mo['systolic']>=$params['s_min'] and $rec_mo['systolic']<$params['s_max'])
                  { $result_ag[$rec_mo['member_id']][$id]++ ;
                    $a=1 ;
                  }
              }
              if ($a) $result_ag[$rec_mo['member_id']]['all_cnt_a']++ ;


            }

            //echo 'удаляем из списка сотрудников тех, у которых число попаданий в группу АГ менее заданного порога<br>' ;
            foreach($arr_members as $member_id=>$cnt_mo)
            {   //print_r($arr_ag_all) ; echo '<br>' ;
                if (!$result_ag[$member_id]['all_cnt_a'])
                { unset($arr_members[$member_id]) ;
                  unset($result_ag[$member_id]) ;
                }
                else
                { $res=round($result_ag[$member_id]['all_cnt_a']/$cnt_mo*100) ;
                  //echo $arr_ag_all['all_cnt_a'].'/'.$arr_members[$member_id].'*100='.$res.'<br>' ;
                  if ($res<$this->filter['min_proc'])
                  { unset($arr_members[$member_id]) ;
                    unset($result_ag[$member_id]) ;
                  }
                }

            }

            //echo 'Всего человек после отсева по минимальному порогу АГ: '._sizeof($arr_members).'<br>' ;
            //echo 'Записей в массие значений АГ: '._sizeof($result_ag).'<br>' ;


            $cnt_member_stat=array_intersect($arr_members_source_prev_ids,$arr_members_source_cur_ids) ;
            //echo 'Считаем число сотрудников, перешедних из прошлого месяца: '._sizeof($cnt_member_stat).'<br>' ;
            $koof_r=($arr_members_source_cur_ids)? round((_sizeof($arr_members_source_cur_ids)-_sizeof($cnt_member_stat))/_sizeof($arr_members_source_cur_ids)*100,1):0 ;
            //echo 'Считаем коэффициент ротации: '._sizeof($cnt_member_stat).'<br>' ;



            //damp_array($arr_members) ;
            //damp_array($result_ag) ;

            $table[$cur_month]['member_cnt']=_sizeof($arr_members_source) ;
            $table[$cur_month]['sr_s']=(_sizeof($result_s_sr))? round((array_sum($result_s_sr)/_sizeof($result_s_sr)),2):0 ;
            $table[$cur_month]['sr_d']=(_sizeof($result_d_sr))? round((array_sum($result_d_sr)/_sizeof($result_d_sr)),2):0 ;
            $table[$cur_month]['sr_age']=(_sizeof($result_age))? round((array_sum($result_age)/_sizeof($result_age)),2):0 ;
            $table[$cur_month]['ag_cnt']=(_sizeof($result_ag))? _sizeof($result_ag):0 ;
            $table[$cur_month]['koof_r']=$koof_r ;
            //$table[$cur_month]['cnt_mo']=$stats_cnt_mo ;
            $table[$cur_month]['cnt_mo_sess']=$stats_cnt_mo_sess ;


            $d1=$table[$cur_month]['ag_cnt'] ;
            $d2=$table[$cur_month]['member_cnt'] ;
            if ($d2) $koof=$d1/$d2*100 ;
            $table[$cur_month]['koof']=round($koof,2) ;

        }

//        print_2x_arr($table) ;
        //print_r($arr_month) ;

        ?><div id="reports_itog2">
          <div id="chart-container">FusionCharts will render here</div>
          <table>
             <tr><th></th>
                 <?if (_sizeof($arr_month)) foreach($arr_month as $date){?><th><?echo $date?></th><?}?>
             </tr>
             <!--<tr>
                 <td><strong>Количество МО</strong><div class="comment">Общее число осмотров за месяц. Для прохождения МО может потребоваться до трех сеансов МО в автоматическом и ручном режиме</div></td>
                 <?if (_sizeof($arr_month)) foreach($arr_month as $t=>$date){?><td><?echo $table[$t]['cnt_mo']?></td><?}?>
             </tr>
             <tr>
                 <td><strong>Количество сеансов МО</strong><div class="comment">Общее число проведенных сеансов МО.</div></td>
                 <?if (_sizeof($arr_month)) foreach($arr_month as $t=>$date){?><td><?echo $table[$t]['cnt_mo_sess']?></td><?}?>
             </tr>-->
             <tr>
                 <td><strong>Количество сотрудников</strong></td>
                 <?if (_sizeof($arr_month)) foreach($arr_month as $t=>$date){?><td><?echo $table[$t]['member_cnt']?></td><?}?>
             </tr>
             <tr>
                 <td><strong>Процент ротации</strong><div class="comment hidden">Процент новых сотрудников в смене относительно общего кол-ва сотрудников за месяц</div></td>
                 <?if (_sizeof($arr_month)) foreach($arr_month as $t=>$date){?><td><?echo $table[$t]['koof_r']?></td><?}?>
             </tr>
             <!--<tr>
                 <td><strong>Среднее давление</strong></td>
                 <?if (_sizeof($arr_month)) foreach($arr_month as $t=>$date){?><td><?echo  $table[$t]['sr_s'].' / '.$table[$t]['sr_d']?></td><?}?>
             </tr>
             <tr>
                 <td><strong>Средний возраст</strong></td>
                 <?if (_sizeof($arr_month)) foreach($arr_month as $t=>$date){?><td><?echo  $table[$t]['sr_age']?></td><?}?>
             </tr>-->
             <tr>
                 <td><strong>Группы АГ</strong></td>
                 <?if (_sizeof($arr_month)) foreach($arr_month as $t=>$date){?><td><?echo  $table[$t]['ag_cnt']?></td><?}?>
             </tr>
             <tr>
                 <td><strong>КАГ</strong></td>
                 <?if (_sizeof($arr_month)) foreach($arr_month as $t=>$date){?><td><?echo $table[$t]['koof']?></td><?}?>
             </tr>

           </table>
           <style type="text/css">
               div#reports_itog2{}
               div#reports_itog2 table{width:100%;table-layout:auto;border-collapse:collapse;}
               div#reports_itog2 th{background:#dddddd;color:black;font-weight:bold;border:1px solid #aaaaaa;}
               div#reports_itog2 td{padding:5px;border:1px solid #aaaaaa;text-align:center;}
               div#reports_itog2 td.left{text-align:left;}
               div#reports_itog2 tr.subitog td{font-weight:bold;}
               div#reports_itog2 tr.itog td{font-weight:bold;background:#dddddd;}
            </style>
           </div>


 <? $caption='Показатели состояния здоровья' ;
    $yAxisName='Месяцы' ;
    /*
    if (_sizeof($arr_category)) foreach($arr_category as $category_name=>$category_title)
    { $arr_category_str[]='{"label": "'.$category_title.'" }' ;
      if (_sizeof($pre_res)) foreach($pre_res as $line_name=>$line_sets)
      {
       if (_sizeof($line_sets[$category_name])>1)
              $res[$line_name][$category_name]=round(array_sum($line_sets[$category_name])/_sizeof($line_sets[$category_name]),2) ;
       else   $res[$line_name][$category_name]=$line_sets[$category_name][0] ;

       $arr_data[$line_name][]='{"value": "'.$res[$line_name][$category_name].'" }' ;
      }
    } */

 ?>
     <script type="text/javascript">
     $j(document).ready(function(){
       FusionCharts.ready(function(){


    var revenueChart2 = new FusionCharts({
        type: 'mscombidy2d',
        renderAt: 'chart-container',
        width: '1000',
        height: '400',
        dataFormat: 'json',
        dataSource: {
            "chart": {
                //"caption": "<?echo $caption?>",
                //"subCaption": "от <? echo date('d.m.Y',$t1).' до '.date('d.m.Y',$t2)?>",
                "xAxisname": "<?echo $yAxisName?>",
                "pYAxisName": "Кол-во",
                "sYAxisName": "Коэффициент артериальной гипертонии",
                "numberPrefix": "",
                "sNumberSuffix" : "",
                //"sYAxisMaxValue" : "50",

                //Cosmetics
                "paletteColors" : "#f2c500,#0075c2,#1aaf5d",
                "baseFontColor" : "#333333",
                "baseFont" : "Helvetica Neue,Arial",
                "captionFontSize" : "14",
                "subcaptionFontSize" : "14",
                "subcaptionFontBold" : "0",
                "showBorder" : "0",
                "bgColor" : "#ffffff",
                "showShadow" : "0",
                "canvasBgColor" : "#ffffff",
                "canvasBorderAlpha" : "0",
                "divlineAlpha" : "100",
                "divlineColor" : "#999999",
                "divlineThickness" : "1",
                "divLineIsDashed" : "1",
                "divLineDashLen" : "1",
                "divLineGapLen" : "1",
                "usePlotGradientColor" : "0",
                "showplotborder" : "0",
                "showXAxisLine" : "1",
                "xAxisLineThickness" : "1",
                "xAxisLineColor" : "#999999",
                "showAlternateHGridColor" : "0",
                "showAlternateVGridColor" : "0",
                "legendBgAlpha" : "0",
                "legendBorderAlpha" : "0",
                "legendShadow" : "0",
                "legendItemFontSize" : "10",
                "legendItemFontColor" : "#666666"
            },
            "categories":
            [{
                "category": [ <?foreach($arr_month as $t=>$date) echo '{ "label": "'.$date.'" },'?>]
            }],
            "dataset":
            [
                {
                    "seriesName": "Количество сотрудников",
                    "data": [ <?foreach($arr_month as $t=>$date) echo '{ "value" : "'.$table[$t]['member_cnt'].'" },'?>]
                },
                {
                    "seriesName": "Группы АГ",
                    "data": [ <?foreach($arr_month as $t=>$date) echo '{ "value" : "'.$table[$t]['ag_cnt'].'" },'?>]
                },
                {
                    "seriesName": "КАГ",
                    "parentYAxis": "S",
                    "renderAs": "line",
                    "showValues": "1",
                    "divlineThickness" : "1",
                    "data": [ <?foreach($arr_month as $t=>$date) echo '{ "value" : "'.$table[$t]['koof'].'" },'?>]
                }
            ]
        }
    });

    revenueChart2.render();
});
     }) ;
     </script>
     <style type="text/css">#chart-container{margin:0 auto;width:1000px;}</style>
   <?







    }
}

?>
