;***************************************************
dialog sms_add_user {
  title "Добавить"
  size -1 -1 132 111
  option dbu

  combo 15, 9 49 53 50, size drop
  combo 16, 68 49 53 50, size drop
  combo 3, 49 71 29 46, size vsbar drop
  combo 2, 11 71 33 46, size vsbar drop
  button "Добавить", 6, 22 93 37 12, ok
  button "Отмена", 7, 74 93 37 12, cancel
  edit "", 4, 82 71 38 10, limit 7
  edit "", 5, 42 6 81 10
  check "Вести лог для адресата", 12, 42 16 70 8
  box "Телефон", 8, 6 30 119 59
  text "Имя", 1, 11 7 25 8
  text "Оператор", 9, 14 62 25 8
  text "Код", 10, 49 62 25 8
  text "Номер", 11, 87 62 25 8
  text "Страна", 13, 10 40 19 8
  text "Регион", 14, 69 40 18 8
}
;***************************************************
alias sms_user_edit {
  sms_add_user
  did -o sms_add_user 6 1 Изменить | dialog -t sms_add_user Редактировать 
  %sms.string = $read($nofile($script) $+ sms_user.txt,$did(sms_dialog,7).sel)
  if ($sms_razb_str(country) != $did(sms_add_user,15)) { did -c sms_add_user 15 $didwm(sms_add_user,15,$sms_razb_str(country)) | sms_add_region sms_add_user 15 16 2 3 }
  if ($sms_razb_str(region) != $did(sms_add_user,16)) { did -c sms_add_user 16 $didwm(sms_add_user,16,$sms_razb_str(region)) | sms_add_op sms_add_user 15 16 2 3 }
  if ($sms_razb_str(op) != $did(sms_add_user,2)) { did -c sms_add_user 2 $didwm(sms_add_user,2,$sms_razb_str(op)) | sms_add_pref sms_add_user 15 16 2 3 }
  if ($sms_razb_str(pref) != $did(sms_add_user,3)) did -c sms_add_user 3 $didwm(sms_add_user,3,$sms_razb_str(pref))
  did -o sms_add_user 4 1 $sms_razb_str(num) | did -o sms_add_user 5 1 $sms_razb_str(name) 
  if ($sms_razb_str(log) == 1) did -c sms_add_user 12
}
;***************************************************
on 1:dialog:sms_add_user:init:*:sms_add_country $dname 15 16 2 3
;***************************************************
on 1:dialog:sms_add_user:sclick:*:{
  if ($did == 15) sms_add_region $dname 15 16 2 3
  if ($did == 16) sms_add_op $dname 15 16 2 3
  if ($did == 2) sms_add_pref $dname 15 16 2 3
  if ($did == 6) {
    if ($did(6).text == Добавить) { write " $+ $nofile($script) $+ sms_user.txt $+ " $did(15) $+ ' $+ $did(16) $+ ' $+ $did(2) $+ ' $+ $did(3) $+ ' $+ $did(4)  $+ ' $+ $did(12).state $+ ' $+ $replace($did(5),$chr(32),$chr(160))
    sms_user_list }
    if ($did(6).text == Изменить) { write -l $+ $did(sms_dialog,7).sel " $+ $nofile($script) $+ sms_user.txt $+ " $did(15) $+ ' $+ $did(16) $+ ' $+ $did(2) $+ ' $+ $did(3) $+ ' $+ $did(4)  $+ ' $+ $did(12).state $+ ' $+ $replace($did(5),$chr(32),$chr(160))
    sms_user_list }
} }
;***************************************************
on 1:dialog:sms_add_user:close:*:{
  if (($dialog(sms_dialog) == $null) && ($dialog(sms_upgrade) == $null) && ($dialog(sms_log) == $null) && ($dialog(sms_extra) == $null) && ($dialog(sms_adds) == $null) && ($dialog(sms_prefer) == $null)) .unload -rs sms_other.mrc
  .unload -rs sms_user.mrc
}
