<?php
include_once("c_pl_clients.php");
class c_page_cab_pl_clients_card extends c_page_cab_pl_clients
{
 public $h1='Карточка клиента ПЛ' ;
 public $rec_client=[] ;

    function select_obj_info()
    { if (_CUR_ID)
      { $this->rec_client=PL()->get_client_by_id(_CUR_ID) ;
        if (!$this->rec_client['pkey']) $this->result=404 ;
      }
    }


  function second_menu_config()
  { if ($this->rec_client['pkey'])
    { $this->second_menu[$this->rec_client['__href']]=array('title'=>'Карточка клиента') ;
      $this->second_menu[$this->rec_client['__href'].'edit/']='Редактировать клиента' ;
      $this->second_menu[$this->rec_client['__href'].'contracts/']='Договора на доступ' ;
      //$this->second_menu[$this->rec_client['__href'].'persons/']='Сотрудники клиента' ;
      $this->second_menu[$this->rec_client['__href'].'db/']='Исходные данные' ;
    }
  }




 function block_main()
 {
     $this->panel_client_info(['readonly'=>1]) ;

 }

 function panel_client_info($options=array())
 {   $org_info=(isset($this->rec_client['_ext_info']['dadata']))? $this->rec_client['_ext_info']['dadata']['suggestions'][0]['data']:null ;

     $readonly=($options['readonly'])? 1:0 ;
     $disabled=($options['readonly'])? 1:0 ;
     //FORM()->form_open(array('class'=>'form-horizontal','col_count'=>6,'col_count_title'=>2)) ;
       FORM()->form_open(['post_array_name'=>'client']) ;

       ?><strong>КЛИЕНТ</strong><br><br><?
       FORM()->row_open() ;
       FORM()->section_input(['name'=>'obj_name','title'=>'Краткое наименование','col_count'=>2,'required'=>1,'value'=>$this->rec_client['obj_name'],'readonly'=>$readonly,'disabled'=>$disabled]);
       FORM()->section_input(['name'=>'email','title'=>'Email','col_count'=>2,'required'=>1,'type'=>'email','value'=>$this->rec_client['email'],'readonly'=>$readonly,'disabled'=>$disabled]);
       FORM()->section_input(['name'=>'phone','title'=>'Телефон','col_count'=>2,'required'=>1,'type'=>'phone','value'=>$this->rec_client['phone'],'readonly'=>$readonly,'disabled'=>$disabled]);
       FORM()->row_close() ;

       ?><strong>ОРГАНИЗАЦИЯ</strong><br><br><?
       FORM()->row_open() ;
       FORM()->section_input(['name'=>'inn','title'=>'ИНН','col_count'=>2,'required'=>1,'value'=>$this->rec_client['inn'],'readonly'=>$readonly,'disabled'=>1]);
       FORM()->section_input(['name'=>'org_name','title'=>'Наименование организации','value'=>$org_info['name']['short_with_opf'],'col_count'=>12,'read_only'=>1]);
       FORM()->section_input(['name'=>'ogrn','title'=>'ОГРН','value'=>$org_info['ogrn'],'col_count'=>6,'read_only'=>1]);
       FORM()->section_input(['name'=>'okpo','title'=>'ОКПО','value'=>$org_info['okpo'],'col_count'=>6,'read_only'=>1]);
       FORM()->section_input(['name'=>'okato','title'=>'ОКАТО','value'=>$org_info['okato'],'col_count'=>6,'read_only'=>1]);
       FORM()->section_input(['name'=>'oktmo','title'=>'ОКАТО','value'=>$org_info['oktmo'],'col_count'=>6,'read_only'=>1]);
       FORM()->section_input(['name'=>'address','title'=>'Адрес','value'=>$org_info['address']['unrestricted_value'],'col_count'=>12,'read_only'=>1]);
       FORM()->row_close() ;

       if (!$readonly) FORM()->button('Сохранить изменения','pl/client_save',['class'=>'v2','client_id'=>$this->rec_client['pkey']]) ;

 }





}



?>
