function _categories($fk_parent = 0, $keyword = '')
{
    global $db, $conf;
    $TFille = array();
    if (!empty($keyword)) {
        $resultset = $db->query("SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie WHERE label LIKE '%" . addslashes($keyword) . "%' ORDER BY label");
        while ($obj = $db->fetch_object($resultset)) {
            $cat = new Categorie($db);
            $cat->fetch($obj->rowid);
            $TFille[] = $cat;
        }
    } else {
        $parent = new Categorie($db);
        if (empty($fk_parent)) {
            if (empty($conf->global->SPC_DO_NOT_LOAD_PARENT_CAT)) {
                $TFille = $parent->get_all_categories(0, true);
            }
        } else {
            $parent->fetch($fk_parent);
            $TFille = $parent->get_filles();
        }
    }
    return $TFille;
}
Ejemplo n.º 2
0
            foreach ($cats as $cat) {
                $ways = $cat->print_all_ways();
                foreach ($ways as $way) {
                    $i = !$i;
                    print "<tr " . $bc[$i] . "><td>" . $way . "</td>";
                    print "<td><a href= '" . DOL_URL_ROOT . "/fourn/product/categorie.php?id=" . $product->id . "&amp;cat=" . $cat->id . "'>" . $langs->trans("DeleteFromCat") . "</a></td></tr>\n";
                }
            }
            print "</table><br/><br/>\n";
        } else {
            if ($cats < 0) {
                print $langs->trans("ErrorUnknown");
            } else {
                print $langs->trans("NoCat") . "<br/><br/>";
            }
        }
    }
    print $langs->trans("AddProductToCat") . "<br/><br/>";
    print '<table class="border" width="100%">';
    print '<form method="POST" action="' . DOL_URL_ROOT . '/fourn/product/categorie.php?id=' . $product->id . '">';
    print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
    print "<tr><td><select name='add_cat'><option value='-1'>" . $langs->trans("Choose") . "</option>";
    $cat = new Categorie($db);
    foreach ($cat->get_all_categories() as $categorie) {
        print "<option value='" . $categorie->id . "'>" . $categorie->label . "</option>\n";
    }
    print "</select></td><td><input type='submit' value='" . $langs->trans("Select") . "'></td></tr>";
    print "</form></table><br/>";
}
$db->close();
llxFooter();
Ejemplo n.º 3
0
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");

if (!$user->rights->categorie->lire) accessforbidden();


llxHeader ("","",$langs->trans("Categories"));

print_fiche_titre ($langs->trans ("CatList"));

print '<table border="0" width="100%" class="notopnoleftnoright">';

print '<tr><td valign="top" width="30%" class="notopnoleft">';

$c = new Categorie ($db);
$cats = $c->get_all_categories ();


if ($cats != -1)
{
  print '<table class="noborder" width="100%">';
  print '<tr class="liste_titre">';
  print '<td>'.$langs->trans("Ref").'</td>';
  print '<td>'.$langs->trans("Description").'</td>';
  print '<td align="right">'.$langs->trans("Type").'</td>';
  print '</tr>';
  
  $var=true;
  foreach ($cats as $cat)
    {
      $var = ! $var;