Example #1
0
        }
        $outjson = array('ref' => $outref, 'label' => $outlabel, 'desc' => $outdesc, 'type' => $outtype, 'price_ht' => $outprice_ht, 'price_ttc' => $outprice_ttc, 'pricebasetype' => $outpricebasetype, 'tva_tx' => $outtva_tx, 'qty' => $outqty, 'discount' => $outdiscount);
    }
    echo json_encode($outjson);
} else {
    require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
    $langs->load("products");
    $langs->load("main");
    top_httphead();
    if (empty($htmlname)) {
        return;
    }
    $match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET));
    sort($match);
    $idprod = !empty($match[0]) ? $match[0] : '';
    if (!GETPOST($htmlname) && !GETPOST($idprod)) {
        return;
    }
    // When used from jQuery, the search term is added as GET param "term".
    $searchkey = GETPOST($idprod) ? GETPOST($idprod) : (GETPOST($htmlname) ? GETPOST($htmlname) : '');
    $form = new Form($db);
    if (empty($mode) || $mode == 1) {
        $arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, 2, $outjson, $socid);
    } elseif ($mode == 2) {
        $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, $socid);
    }
    $db->close();
    if ($outjson) {
        print json_encode($arrayresult);
    }
}