<?
include_once(_DIR_EXT.'/HTML/c_page_XML_AJAX.php') ;
//include_once('messages.php') ;
class c_page_ajax extends c_page_XML_AJAX
{
    function create_personal_workorder()
    { if ($_POST['filter']['data_from'] and $_POST['filter']['data_to'] and $_POST['filter']['car_number'])
      { $result=WO()->create_personal_workorder($_POST['personal_id'],$_POST['filter']) ;
       //$this->add_element('TURN_use_QR_code',$_SESSION['TURN_use_QR_code']) ;
       $this->update_page=1 ;
      }
      else $this->add_element('show_notife','Заполните все необходимые поля') ;
    }

    function create_response_technic()
    {
        WO()->create_response_technic($_POST['wo_id']) ;
        $this->update_page=1 ;
    }

    public function getMOInfo()
       { $propusk_id=$_POST['passNumber'] ;
         $rec_person=PERSONAL()->get_personal(array('propusk'=>$propusk_id,'tab_number'=>$propusk_id),array('only_enabled'=>1,'set_rules'=>1,'set_QR_code'=>$GLOBALS['LS_person_field_to_qrcode'],'dop_usl'=>'enabled=1')) ;
         if ($rec_person['pkey'])
         {   $rec_wo=WO()->get_current_work_order_to_personal($rec_person['pkey']) ;
             if ($rec_wo['mo_id'])
             {   if ($rec_wo['tech_status']==1)
                 {   ob_start() ;
                     $doc_url=WO()->generate_put_list($rec_wo['pkey']) ;
                     ob_end_clean() ;
                    //$text='<iframe src="'.$doc_url.'" style="width:100%; height:700px;" frameborder="0" /></iframe>' ;
                    //$text=$doc_url.'<br><iframe src=\''.$doc_url.'\' frameborder=\'0\'></iframe>' ;
                     $this->add_element('JSCODE','<script type="text/javascript">
                                var wnd=window.open(\''.$doc_url.'\',\'window_print\',\'status=1,dependent=1,width=800,height=1000,left=0,top=0, resizable=1, scrollbars=yes\') ;
                                wnd.focus();
                                setTimeout(function(){wnd.print();}, 1000);

                                                                    resetInput();
                                                                 </script>') ;
                 }
                 else if ($rec_wo['tech_status']==2)
                 {
                    $this->add_element('gettingData.HTML','Техосмотр не пройден') ;
                    $this->add_element('JSCODE','<script type="text/javascript">resetInput(1500);</script>') ;
                 }
                 else
                 {
                    $this->add_element('gettingData.HTML','<div style="text-align:center;">
                    <button class="button v2" cmd="work_order/request_tech" style="float:none;margin:0 auto;">Вызвать техника</button>&nbsp;
                    <button  class="button v2 red" cmd="work_order/request_tech"  style="float:none;margin:0 auto;">Автомобиль неисправен</button></div>') ;
                    //$this->add_element('JSCODE','<script type="text/javascript">resetInput(1500);</script>') ;
                 }

             }
             else
             {
                 $this->add_element('gettingData.HTML','МО не пройден') ;
                 $this->add_element('JSCODE','<script type="text/javascript">resetInput(1500);</script>') ;

             }
         }
         else
         {
             $this->add_element('gettingData.HTML','Сотрудник не найден') ;
             $this->add_element('JSCODE','<script type="text/javascript">resetInput(1500);</script>') ;
         }
       }



       function request_tech()
       {
           //$this->add_element('JSCODE','<script type="text/javascript">resetInput(1500);</script>') ;
           $this->update_page=1 ;
       }






}
