예제 #1
0
function display_categories($type = 'list', $parent = 0)
{
    $return = '';
    $cats = _categories();
    if ($cats != '') {
        foreach ($cats as $cat) {
            if ($cat->parent == $parent) {
                switch ($type) {
                    case 'option':
                        $return .= "<option value=\"{$cat->id}\">{$cat->name}</option>";
                        break;
                    case 'optionurl':
                        $return .= "<option value=\"/shop/category/{$cat->uri}\">{$cat->name}</option>";
                        break;
                    case 'list':
                        $return .= "<a href=\"/shop/category/{$cat->uri}\" title=\"{$cat->name}\">{$cat->name}</a>, ";
                        break;
                    case 'links':
                        $return[$cat->id] = "<a href=\"/shop/category/{$cat->uri}\" title=\"{$cat->name}\">{$cat->name}</a>";
                        break;
                    default:
                        $return[$cat->id] = $cat->name;
                        break;
                }
            }
        }
    } else {
        $return = null;
    }
    return $return;
}
<?php

require '../config.php';
dol_include_once('/categories/class/categorie.class.php');
dol_include_once('/product/class/product.class.php');
dol_include_once('/comm/propal/class/propal.class.php');
dol_include_once('/commande/class/commande.class.php');
dol_include_once('/compta/facture/class/facture.class.php');
$get = GETPOST('get');
$put = GETPOST('put');
switch ($get) {
    case 'categories':
        $fk_parent = (int) GETPOST('fk_parent');
        $keyword = GETPOST('keyword');
        $Tab = array('TCategory' => _categories($fk_parent, $keyword), 'TProduct' => _products($fk_parent));
        __out($Tab, 'json');
        break;
}
switch ($put) {
    case 'addline':
        $object_type = GETPOST('object_type');
        $object_id = (int) GETPOST('object_id');
        $qty = (double) GETPOST('qty');
        $TProduct = GETPOST('TProduct');
        $txtva = (double) GETPOST('txtva');
        if (!empty($TProduct)) {
            $o = new $object_type($db);
            //$o=new Propal($db);
            $o->fetch($object_id);
            foreach ($TProduct as $fk_product) {
                $p = new Product($db);