| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * MyCustomSListBoxManager |
|---|
| 5 | * |
|---|
| 6 | * @author Tomasz Świenty |
|---|
| 7 | * @version 0.1 |
|---|
| 8 | * @copyright Copyright (c) eDokumenty |
|---|
| 9 | */ |
|---|
| 10 | final class MyCustomSListBoxManager { |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | public function setByPKey($params) { |
|---|
| 15 | |
|---|
| 16 | $data = JSON::toArray($params); |
|---|
| 17 | $povcid = $data['povcid']; |
|---|
| 18 | $name__ = $data['name__']; |
|---|
| 19 | |
|---|
| 20 | require_once(LIB_PATH.'forms/SListBox.inc'); |
|---|
| 21 | $lookup = new SListBox($name__); |
|---|
| 22 | |
|---|
| 23 | if (is_numeric($povcid)) { |
|---|
| 24 | $lookup->setValue($povcid); |
|---|
| 25 | return $lookup->toHtml(FALSE); |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | return FALSE; |
|---|
| 29 | |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | final public static function manage(SListBox $lookup, $params = array()) { |
|---|
| 35 | |
|---|
| 36 | $lookupName = $lookup->getName(); |
|---|
| 37 | |
|---|
| 38 | $dHWND = Application::registerDialog(Application::getShortName($lookupName.'CustomAsyncTreeDialog'), 'CustomAsyncTreeDialog', './scripts/CustomAsyncTreeDialog.inc'); |
|---|
| 39 | |
|---|
| 40 | $newContactIcon = new ImgFormButton(array( |
|---|
| 41 | 'name' => $lookupName.'_NewContactIcon', |
|---|
| 42 | 'submit' => FALSE, |
|---|
| 43 | 'image' => IMG_PATH.'toolbarIcons/list.png', |
|---|
| 44 | 'title' => Translator::translate('Dodaj z listy') |
|---|
| 45 | )); |
|---|
| 46 | |
|---|
| 47 | $newContactIcon->script = 'App.openDialogEx(\''.$dHWND.'\', null, ({onAdd:\'App.'.$lookupName.'onAdd\'}).toJSONString())'; |
|---|
| 48 | |
|---|
| 49 | $lookup->addIcon($newContactIcon); |
|---|
| 50 | |
|---|
| 51 | JScript::add(' |
|---|
| 52 | App.'.$lookupName.'onAdd = function(povcid) { |
|---|
| 53 | $(\''.$lookupName.'v\').value = povcid; |
|---|
| 54 | asyncLibrary.execute(\'./scripts/MyCustomSListBoxManager.inc\',\'MyCustomSListBoxManager\', \'\', \'setByPKey\', ({povcid:povcid,name__:\''.$lookupName.'\'}).toJSONString(), \'if(text) {DOMO.replaceWithHTML($(\\\''.$lookupName.SListBox::INPUT_PREFIX.'\\\'), text);}\', null,FAST); |
|---|
| 55 | } |
|---|
| 56 | '); |
|---|
| 57 | |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | } // class MyCustomSListBoxManager |
|---|
| 61 | |
|---|
| 62 | ?> |
|---|