Example #1
0
function get_product_categories($parent_id, $open_nodes_ids = array())
{
    $href_string = "javascript:set_return('productcategories')";
    reset($open_nodes_ids);
    $nodes = array();
    if ($parent_id == '') {
        $query = "select * from product_categories where (parent_id is null or parent_id='') and deleted=0 order by list_order";
    } else {
        $query = "select * from product_categories where parent_id ='{$parent_id}' and deleted=0 order by list_order";
    }
    $result = $GLOBALS['db']->query($query);
    while (($row = $GLOBALS['db']->fetchByAssoc($result)) != null) {
        $node = new Node($row['id'], $row['name']);
        $node->set_property("href", $href_string);
        if (count($open_nodes_ids) > 0 and $row['id'] == current($open_nodes_ids)) {
            $node->expanded = true;
            $node->dynamic_load = false;
            $current_id = current($open_nodes_ids);
            array_shift($open_nodes_ids);
            $child_nodes = get_product_categories($current_id, $open_nodes_ids);
            //add all returned node to current node.
            foreach ($child_nodes as $child_node) {
                $node->add_node($child_node);
            }
        } else {
            $node->expanded = false;
            $node->dynamic_load = true;
        }
        $nodes[] = $node;
    }
    return $nodes;
}
<div class="column-3 sidebar">
	<?php 
/* if(is_user_logged_in()){ 	
			$your_compound_page=2219;
			query_posts('post_type=page&p='.$your_compound_page);
			if(have_posts()):while(have_posts()):the_post();
	?>
	<section role="own-compound">
		<div class="shop-header">
			<h6 class="heading"><a href="<?php the_permalink();?>"><?php the_title();?></a></h6>
		</div>
	</section>
	<?php 
		endwhile;endif;wp_reset_query();
	}*/
?>
	<section role="category"><?php 
get_product_categories();
?>
</section>
	<section role="body-systems"></section>
	<section role="actions"></section>	
	<section role="indications"></section>	
</div>
Example #3
0
    function process_page()
    {
        global $mod_strings, $app_strings, $currentModule, $seed_object, $sugar_version, $sugar_config;
        $focus = BeanFactory::getBean('ProductCategories');
        if (!isset($_REQUEST['html'])) {
            $xtpl = new XTemplate('modules/ProductCategories/Popup_picker.html');
            $GLOBALS['log']->debug("using file modules/ProductCategories/Popup_picker1.html");
        } else {
            $_REQUEST['html'] = preg_replace("/[^a-zA-Z0-9_]/", "", $_REQUEST['html']);
            $GLOBALS['log']->debug("_REQUEST['html'] is " . $_REQUEST['html']);
            $xtpl = new XTemplate('modules/ProductCategories/' . $_REQUEST['html'] . '.html');
            $GLOBALS['log']->debug("using file modules/ProductCategories/" . $_REQUEST['html'] . '.html');
        }
        insert_popup_header();
        //tree header.
        $prodcattree = new Tree('productcategories');
        $prodcattree->set_param('module', 'ProductCategories');
        $parents = array();
        if (!empty($_REQUEST['parent_category_id'])) {
            $parents = $this->find_parents($_REQUEST['parent_category_id']);
        }
        $nodes = get_product_categories(null, $parents);
        foreach ($nodes as $node) {
            $prodcattree->add_node($node);
        }
        $xtpl->assign("TREEHEADER", $prodcattree->generate_header());
        $xtpl->assign("TREEINSTANCE", $prodcattree->generate_nodes_array());
        $xtpl->assign("MODULE_NAME", $currentModule);
        global $sugar_config;
        $site_data = "<script> var site_url= {\"site_url\":\"" . getJavascriptSiteURL() . "\"};</script>\n";
        $xtpl->assign("SITEURL", $site_data);
        if (!empty($_REQUEST['form']) && $_REQUEST['form'] == 'EditView') {
            $the_javascript = "<script type='text/javascript' language='JavaScript'>\n";
            $the_javascript .= "function set_return(treeid) { \n";
            $the_javascript .= "    node=YAHOO.namespace(treeid).selectednode;";
            $the_javascript .= "    window.opener.document.EditView.parent_id.value = node.data.id;\n";
            $the_javascript .= "    window.opener.document.EditView.parent_name.value = node.label;\n";
            $the_javascript .= "     window.close();\n";
            $the_javascript .= "}\n";
            $the_javascript .= "</script>\n";
            $clear_button = "<input title='" . $app_strings['LBL_CLEAR_BUTTON_TITLE'] . "' class='button' LANGUAGE=javascript onclick=\"window.opener.document.EditView.parent_id.value = '';window.opener.document.EditView.parent_name.value = ''; window.close()\" type='submit' name='button' value='  " . $app_strings['LBL_CLEAR_BUTTON_LABEL'] . "  '>\n";
            $cancel_button = "<input title='" . $app_strings['LBL_CANCEL_BUTTON_TITLE'] . "' accessKey='" . $app_strings['LBL_CANCEL_BUTTON_KEY'] . "' class='button' LANGUAGE=javascript onclick=\"window.close()\" type='submit' name='button' value='  " . $app_strings['LBL_CANCEL_BUTTON_LABEL'] . "  '>\n";
        }
        if (empty($_REQUEST['form']) || $_REQUEST['form'] == 'EditView' && $_REQUEST['tree'] == 'ProdCat') {
            $seed_object->show_products = FALSE;
            $the_javascript = <<<END
            <script type='text/javascript' language='JavaScript'>
                var field_id = null;
                var field_name = null;

                function set_return(treeid) {

                    if(typeof treeid != 'undefined') {
                        node=YAHOO.namespace(treeid).selectednode;
                    } else {
                        node = {'data': {'id': ''}, 'label': ''};
                    }

                    if (typeof window.opener.document.forms.search_form != 'undefined' || window.opener.document.forms.popup_query_form != 'undefined') { // Search
                        var form = (typeof window.opener.document.forms.search_form != 'undefined') ? window.opener.document.forms.search_form : window.opener.document.forms.popup_query_form;
                        var searchType = (typeof form.searchFormTab != 'undefined' && form.searchFormTab.value == 'basic_search') ? 'basic' : 'advanced';

                        field_id = form['category_id_'   + searchType];
                        field_name = form['category_name_'   + searchType];
                    } else if(typeof window.opener.document.ReportsWizardForm != 'undefined') { // reports
                        field_id = window.opener.document.ReportsWizardForm['ProductCategories:name:id:1'];
                        field_name = window.opener.document.ReportsWizardForm['ProductCategories:name:name:1'];
                    } else if(typeof window.opener.document.EditView != 'undefined') {
                        field_id = window.opener.document.EditView.category_id;
                        field_name = window.opener.document.EditView.category_name;
                    }

                    if(field_id != null && field_name != null) {
                        field_id.value = node.data.id;
                        field_name.value = node.label;
                    }

                    window.close();
                }
            </script>
END;
            $clear_button = "<input title='" . $app_strings['LBL_CLEAR_BUTTON_TITLE'] . "' class='button' LANGUAGE=javascript onclick=\"set_return()\" type='submit' name='button' value='  " . $app_strings['LBL_CLEAR_BUTTON_LABEL'] . "  '>\n";
            $cancel_button = "<input title='" . $app_strings['LBL_CANCEL_BUTTON_TITLE'] . "' class='button' LANGUAGE=javascript onclick=\"window.close()\" type='submit' name='button' value='  " . $app_strings['LBL_CANCEL_BUTTON_LABEL'] . "  '>\n";
        }
        $xtpl->assign("SET_RETURN_JS", $the_javascript);
        $xtpl->assign("CLEAR_BUTTON", $clear_button);
        $xtpl->assign("CANCEL_BUTTON", $cancel_button);
        $xtpl->parse('main');
        $xtpl->out('main');
    }