<?php

include_once("c_client.php");
class c_page_cab_client_driver_create extends c_page_cab_client
{
    public $h1='Добавление нового водителя' ;

    function block_main()
    { reboot_engine() ;
      $this->page_title() ;
      $this->panel_driver_create() ;
    }

    function panel_driver_create()
    {
      ?><div id="panel_personal_edit">
        <form>
        <table id="panel_personal_edit" class="info">
         <tr><td>ФИО:</td><td><input type="text" name="driver[name]" class="big" data-required value=""></td></tr>
         <tr><td>Номер водительского удостоверения:</td><td><input type="text" name="driver[driving]" id="driving" _is_checked="aspmo/check_propusk_to_unique" value=""> <div class=status></div>
         <tr><td>Дата выдачи мед.справки:</td><td><input type="text" name="driver[s_medspravka]" data-required value="" mask="99.99.9999"></td></tr>
         <tr><td>Дата рождения:</td><td><input type="text" name="driver[dr]" data-required value="" mask="99.99.9999"></td></tr>
         <tr><td>Пол:</td><td><label><input type="radio" name="driver[pol]" value="0" checked>Мужской</label>
                              <label><input type="radio" name="driver[pol]" value="1">Женский</label>
                         </td>
         </tr>
         <tr><td>Автопарк:</td><td><select name="driver[park_id]"  id="park_id"><?
               if (_sizeof(PERSONAL()->tree[$this->client->main_org_id]->list_obj)) foreach(PERSONAL()->tree[$this->client->main_org_id]->list_obj as $org_id) {?><option value="<?echo $org_id?>"><?echo PERSONAL()->tree[$org_id]->name?></option><?}

            ?></select></td></tr>

         <tr><td>Новый автопарк:</td><td><div style="position:relative;"><input type="text" id="driver[new_park_name]" name="new_park_name" class="big" value=""></td></tr>
       </table>
       <div class="buttons">
           <input type="submit" class="v1" cmd="create_driver" value="Добавить водителя" validate="form">
       </div>
       </form></div><?
    }


    function CMD_create_driver()
     { //damp_array($_POST) ;
       $data['clss']=211 ;
       $data['parent']=($_POST['driver']['park_id'])? $_POST['driver']['park_id']:$this->client->main_org_id ;
       $data['s_medspravka']=strtotime($_POST['driver']['s_medspravka']) ;
       $data['dr']=$_POST['driver']['dr'] ;
       $data['pol']=$_POST['driver']['pol'] ;
       $data['obj_name']=$_POST['driver']['name'] ;
       $data['driving']=$_POST['driver']['driving'] ;

       //$data['typ']=$_POST['driver']['typ'] ;
       //$data['permit']=$_POST['driver']['permit'] ;
       $id=adding_rec_to_table('obj_site_personals',$data) ;
       if ($id) {?><div class="green center">Водитель успешно добавлен</div><?
                 update_rec_in_table('obj_site_personals',array('propusk'=>$id),'pkey='.$id) ;
                 $recs[]=PERSONAL()->get_personal_by_id($id) ;
                 print_template($recs,'aspmo_personal/list_personal_table_img') ;
                }
       else     {?><div class="red center">Не удалоль добавить водителя</div><?}
     }


}



?>
