<?
  // шаблон одной стоки списка сессии МО
  function list_work_mo_tr(&$rec,$options=array())
  { ?><tr class=item id="mo_tr_<?echo $rec['pkey']?>">
                <td><?echo $options['i'] ; ?><br><br><a class="new_window"  target="_blank" title="win_second" href="<?echo $rec['__href']?>"><?echo $rec['pkey']?></a><?if ($rec['member_demo_access']){?><div class="demo_access" title="Сотрудник может проходить неограниченное число МО"></div><?}?></td>
                <td><?echo $rec['_data']?><br><br>
                    <?echo ($rec['hand_check_user_id'])? '<img src="/images/doctor2.png" title="'.$rec['_hand_check_user_name'].'"><br>'.$rec['_hand_check_user_name']:$rec['terminal_name']?><br><br>
                    <?echo $rec['_tk_name']?><br><?echo $rec['model']?><br><?echo $rec['_model_name']?>
                </td>
                <td class="name left result"><a class="new_window"  target="_blank" title="win_second" href="<?echo $rec['__href']?>"><?echo $rec['member_name']?></a>
                    <?//$rec_personal=PERSONAL()->get_personal_by_id($rec['member_id']) ;
                    $arr=array() ;
                    if ($rec['member_id'])$arr=array( 'ID'=>$rec['member_id'],
                                                      'ID организации'=>$rec['_ord_id'],
                                                      'название организации'=>$rec['_org_name'],
                                                      'ID отдела'=>$rec['_otdel_id'],
                                                      'название отдела'=>$rec['_otdel_name']
                                        )  ;
                      damp_array($arr,1,-1) ;
                      if (!$rec['member_enabled']) echo '<div class="red">УВОЛЕН</div>' ;
                    ?>

                </td>
                <td class="photo"><div>
                    <div class="img"><? if ($rec['_member_img']) { ?><img width=100 src="<?echo $rec['_member_img']?>"><?}?></div>
                    <div class="img"><? if ($rec['_member_img_auth']) {?><img width=100 src="<?echo $rec['_member_img_auth']?>"><?}?></div>
                    <div class="img"><? if ($rec['_member_img_alco']) {?><img width=100 src="<?echo $rec['_member_img_alco']?>"><?}?></div>
                    <div class="clear"></div></div>
                </td>
                <td class="result">
                  <?if ($rec['status']==2 or $rec['status']==3 or ($rec['status']==4 and $rec['error']==5)){?>
                    <table>
                        <? if ($rec['alcotester'])  {?><tr><td>Алкоголь:</td><td><?echo $rec['_alko']?></td></tr><?}?>
                        <? if ($rec['pupilometer'])  {?><tr><td>Пупилометр:</td><td class="<?if ($rec['_narko_icon']){?>preview_graf left<?}?>">
                              <div><?echo $rec['_narko_icon'];?><div class="panel_PP_preview" mo_id="<?echo $rec['mo_id']?>" id="panel_PP_preview_<?echo $rec['mo_id']?>"></div></div>
                              </td></tr><?}?>
                        <? if ($rec['tonometer'])  {?><tr><td>Артериальное давление:</td><td><?echo $rec['_sd']?></td></tr><?}?>
                        <? if ($rec['pulsometer'])  {?><tr><td>Пульс:</td><td><?echo $rec['_pulse']?></td></tr><?}?>
                        <? if ($rec['thermometer'])  {?><tr><td>Температура:</td><td><?echo $rec['_temperature']?></td></tr><?}?>
                        <? if ($rec['vcheck'])  {?><tr><td>ТКТ:</td><td><?echo $rec['_vcheck']?></td></tr><?}?>
                    </table><?}?>
                  </td>
                <!--<td><?if ($rec['status']==2 or $rec['status']==3) echo $rec['_question']?></td>-->
                <td class="comment"><? if ($rec['status']==2) echo '<div class=ok>'.$rec['_status_name'].'</div>' ; echo $rec['_comment']?></td>
                <td class="dopusk_<?echo $rec['dopusk']?>">
                    <? echo $rec['_dopusk_status'] ;
                       if ($rec['status']==2 and !$rec['dopusk']) {?>Ожидание допуска врачом<?}

                    ?>
                </td>
                <td class="left result">
                    <? $rec_to=CAR_TO()->get_TO_by_mo($rec['pkey']) ;
                       //damp_array($rec_to) ;
                       $arr=array() ;
                       if ($rec_to['pkey'])    $arr=array('ID ТО'=>$rec_to['pkey'],
                                                          'ТО'=>$rec_to['_status'],
                                                          'Дата выдачи ПЛ'=>date('d.m.Y H:i',$rec_to['c_data']),
                                                          'Срок действия ПЛ'=>date('d.m.Y H:i',$rec_to['e_data']),
                                                          'Номер авто'=>$rec_to['car_number'],
                                                          'Техник'=>$rec_to['_member_name'],
                                                          'Карточка ТО'=>'<a href="/cab/rmt/to/'.$rec_to['pkey'].'/" target=_blank>Карточка ТО</a>',
                                                          'Путевой лист'=>'<a href="/docs/'.$rec_to['doc_name'].'" target=_blank>Путевой лист</a>'
                                                        )  ;
                       damp_array($arr,1,-1) ;
                    ?>
                </td>
                <td class="left bill result">
                    <? $recs_bill=ESMO_BILLING()->get_bill_to_mo($rec['pkey']) ;
                       $recs_bill2=group_by_field('member_from',$recs_bill) ;
                       //damp_array($recs_bill2) ;
                       if (_sizeof($recs_bill2)) foreach($recs_bill2 as $member_from=>$recs_from)
                       {   $rec_bill=$recs_from[0] ;
                           $arr=array('ID списания'=>$rec_bill['pkey'],
                                      'ID зачисления'=>$recs_from[1]['pkey'],
                                      'дата операции'=>date('d.m.Y H:i:s',$rec_bill['c_data']),
                                      'от кого'=>$rec_bill['_member_from_name'],
                                      'кому'=>$rec_bill['_member_to_name'],
                                      'тариф'=>($rec_bill['tarif'])? _IL('IL_tarif')->recs[$rec_bill['tarif']]['obj_name']:'Базовый',
                                      'сумма'=>$rec_bill['value']
                                    )  ;
                          damp_array($arr,1,-1) ;
                       }
                    ?>

                </td>
            </tr>
      <?
  }

?>
