' . "TREE" . ''; $params['toolbar'] []= '' . "SERVICE_TREE_TEST" . ''; // init columns if not set if (empty($_SESSION['USERS2_PRODUKT' . "_COLUMN"])) { SEF('USERS_COLUMN_INIT2'); USERS_COLUMN_INIT2('USERS2_PRODUKT', '', 'RWX'); // desc $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['P_ID']="Parent ID"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['A_STATUS']=""; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['A_STATUS_INFO']=""; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['P_NAME']="Nazwa produktu"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['S_OTHER_INFO']=""; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['SES_SERVICE']="Usługa"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['SES_SERVICE_PARENT']="Usługa nadrzędna"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['SES_OPTION_REQUIRED']="Czy opcja jest wymagana"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['SES_PARENT_REQUIRED']="Czy usługa nadrzędna jest wymagana"; //$_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['P_S_PARAM1']="";// TODO: tech //$_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['P_S_PARAM2']="";// TODO: tech //$_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['P_S_LIMIT']="";// TODO: tech //$_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['P_S_LAN']="";// TODO: tech $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['ID_COSTS_GROUPS']=""; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['DESC_TO_LANG']['A_ADM_COMPANY']=""; // perms $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['P_ID']="RWXC"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['A_STATUS']="RWX"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['A_STATUS_INFO']="RWX"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['P_NAME']="RWXC"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['S_OTHER_INFO']="RWXC"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['SES_SERVICE']="RWXC"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['SES_SERVICE_PARENT']="RWXC"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['SES_OPTION_REQUIRED']="RWXC"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['SES_PARENT_REQUIRED']="RWXC"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['P_S_PARAM1']="RWXC"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['P_S_PARAM2']="RWXC"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['P_S_LIMIT']="RWXC"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['P_S_LAN']="RWXC"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['ID_COSTS_GROUPS']="RWXC"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['PERMEDIT']['A_ADM_COMPANY']=""; // base functions $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['FUNCPERMEDIT']['NEW_RECORD']="RWX"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['FUNCPERMEDIT']['TABLE_INSERTDB']="RWX"; // additional functions $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['FUNCPERMEDIT']['ID_COSTS_GROUPS']="RWX"; $_SESSION['USERS2_PRODUKT' . "_COLUMN"]['TYPESPECIAL']['ID_COSTS_GROUPS']="ID_COSTS_GROUPS"; } // router global $ARG1, $ARG1_VAL; switch ($ARG1) { case 'TREE': USERS2_PRODUKT_TREE(); break; case 'SES_TREE': USERS2_PRODUKT_SES_TREE(); break; default: WIEVTABLE( $params ); echo ''; //echo ''; echo ''; echo ''; echo ''; echo ''; } } function USERS2_PRODUKT_EDIT() { EDIT_TABLE_RECORD(); } function USERS2_PRODUKT_HIST() { WIEVTABLE_HIST(); } function USERS2_PRODUKT_TREE() { global $thiss; echo '

'; echo '' . "PRODUKTY" . ''; echo " » "; echo "Tree"; echo '

'; $items = array(); $sql = "select * from `" . $thiss->DETECT_TABLE_NAME . "` where `A_STATUS` not in('DELETED') "; $res = DB::query( $sql ); while ($r = DB::fetch( $res )) { $items [$r->ID] = $r; } Lib::loadClass('Tree'); // build tree by P_ID - array or 0 function Tree_Helper__create_tree_rec( $p_id, &$items ) { static $rec_ind; $rec_ind++; $ret = array(); if (!array_key_exists($p_id, $items)) { return false; } else { $r = $items[$p_id]; if (empty($r->sub)) { return false; } foreach ($r->sub as $k_id => $v) { $ret [$k_id] = Tree_Helper__create_tree_rec( $k_id, $items ); }//end foreach return $ret; } } //echo'
items: ';print_r($items);echo'
'; $items_tree = array();// tree root // -- foreach ($items as $k_id => $r) { if ($r->P_ID == 0) { $items_tree [ $r->ID ] = array(); if (array_key_exists($r->P_ID, $items)) { $items[$r->P_ID]->sub [$r->ID] = true; } } else {// array if (array_key_exists($r->P_ID, $items)) { $items[$r->P_ID]->sub [$r->ID] = true; } } }//end foreach ksort($items_tree); // set up has_childrens foreach ($items as $k_id => $r) { $items[$k_id]->has_childrens = !empty($r->sub); }//end foreach foreach ($items_tree as $k_id => $v_childrens) { if (array_key_exists($k_id, $items)) { $items_tree[$k_id] = Tree_Helper__create_tree_rec( $k_id, $items ); } } function tree_callback__show_item_from_USERS2_PRODUKT( &$r, &$tree ) { $cls = array(); $cls = (!empty($cls))? ' class="'.implode(' ', $cls).'"' : ''; echo''; echo'
'; $out_id = ($r->ID < 10)? ' '.$r->ID.'' : $r->ID; echo''.$out_id.''; echo''; //echo''.$r->A_STATUS.''; echo' '.$r->P_NAME.''; echo " " . $r->SES_SERVICE; echo " " . $r->SES_SERVICE_PARENT; echo " " . $r->SES_OPTION_REQUIRED; echo''; echo'
'; echo''."\n"; } $tree = new Tree( 'USERS2_PRODUKT' ); $tree->set_parent_id_col( 'P_ID' ); $tree->set_param('show_item_callback', "tree_callback__show_item_from_USERS2_PRODUKT"); $tree->set_param('ajax', "NIE"); $tree->set_param('rozwin', true); echo ''; $tree->show_css(); echo ''; $tree->show_js(); echo "\n".'
'."\n"; $tree->show_rec_by_tree($items_tree, $items); echo '
'."\n"; } function USERS2_PRODUKT_SES_TREE() { global $thiss; echo '

'; echo '' . "PRODUKTY" . ''; echo " » "; echo "SERVICE TREE"; echo '

'; function tree_callback__show_item_from_USERS2_PRODUKT( &$r, &$tree ) { $cls = array(); $cls = (!empty($cls))? ' class="'.implode(' ', $cls).'"' : ''; echo''; echo'
'; $out_id = ($r->ID < 10)? ' '.$r->ID.'' : $r->ID; echo''.$out_id.''; echo''; // select service if (!in_array($r->SES_SERVICE, array('GRUPA', 'SERWIS'))) { $js = "return Tree_USERS2_PRODUKT_select_service(this, '" . $r->ID . "', '" . $r->SES_SERVICE . "');"; $checked = ($tree->get_param('selected_opcje_' . $r->SES_SERVICE))? ' checked="checked"' : ''; echo 'ID . '" ' . $checked . ' onclick="' . $js . '">'; } echo' '.$r->P_NAME.''; if ($r->SES_SERVICE == 'OPCJA') { if ($r->SES_OPTION_REQUIRED == 'TAK') { echo "OPCJA wymagana"; } echo " dla " . $r->SES_SERVICE_PARENT . ""; } else { echo " " . $r->SES_SERVICE . ""; if ($r->SES_SERVICE_PARENT) { echo " podrzędna pod " . $r->SES_SERVICE_PARENT . ""; } } echo''; echo'
'; echo''."\n"; } $items = array(); $items_opcje = array(); $sql = "select * from `" . $thiss->DETECT_TABLE_NAME . "` where `A_STATUS` not in('DELETED') "; $res = DB::query( $sql ); while ($r = DB::fetch( $res )) { if ($r->SES_SERVICE == 'OPCJA') { $items_opcje [$r->SES_SERVICE_PARENT] [$r->ID]= $r; } else { $items [$r->ID] = $r; } } Lib::loadClass('Tree'); // build tree by P_ID - array or 0 function Tree_Helper__create_tree_rec( $p_id, &$items ) { static $rec_ind; $rec_ind++; $ret = array(); if (!array_key_exists($p_id, $items)) { return false; } else { $r = $items[$p_id]; if (empty($r->sub)) { return false; } foreach ($r->sub as $k_id => $v) { $ret [$k_id] = Tree_Helper__create_tree_rec( $k_id, $items ); }//end foreach return $ret; } } //echo'
items: ';print_r($items);echo'
'; $items_tree = array();// tree root // -- foreach ($items as $k_id => $r) { if ($r->P_ID == 0) { $items_tree [ $r->ID ] = array(); if (array_key_exists($r->P_ID, $items)) { $items[$r->P_ID]->sub [$r->ID] = true; } } else {// array if (array_key_exists($r->P_ID, $items)) { $items[$r->P_ID]->sub [$r->ID] = true; } } }//end foreach ksort($items_tree); // set up has_childrens foreach ($items as $k_id => $r) { $items[$k_id]->has_childrens = !empty($r->sub); }//end foreach foreach ($items_tree as $k_id => $v_childrens) { if (array_key_exists($k_id, $items)) { $items_tree[$k_id] = Tree_Helper__create_tree_rec( $k_id, $items ); } } $tree = new Tree( 'USERS2_PRODUKT' ); $tree->set_parent_id_col( 'P_ID' ); $tree->set_param('show_item_callback', "tree_callback__show_item_from_USERS2_PRODUKT"); $tree->set_param('ajax', "NIE"); $tree->set_param('rozwin', true); echo ''; $tree->show_css(); echo ''; echo ''; $tree->show_js(); echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo "\n".'
'."\n"; echo '' . "Usługi" . ''; $tree->show_rec_by_tree($items_tree, $items); echo '
'."\n"; echo '
'; echo '
'; echo '' . "Dodatkowe opcje" . ''; foreach ($items_opcje as $k_service => $v_options_arr) { echo ''; }//end foreach echo '
'; echo '
'; }