codesniffer

This commit is contained in:
Florian Henry 2014-02-23 20:10:05 +01:00
parent 4cbdf32ae6
commit ec8ad9f8bb
5 changed files with 4543 additions and 5478 deletions

View File

@ -94,9 +94,7 @@ if ($id > 0 || ! empty($ref)) {
} }
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array ( $hookmanager->initHooks(array('propalcard'));
'propalcard'
));
$permissionnote = $user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php $permissionnote = $user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php
@ -104,13 +102,12 @@ $permissionnote = $user->rights->propale->creer; // Used by the include of actio
* Actions * Actions
*/ */
$parameters = array ( $parameters = array('socid' => $socid);
'socid' => $socid $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
); // hooks
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes') { if ($action == 'confirm_clone' && $confirm == 'yes') {
if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) {
@ -574,7 +571,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
// Unset extrafield // Unset extrafield
if (is_array($extralabelsline)) { if (is_array($extralabelsline)) {
// Get extra fields // Get extra fields
foreach ( $extralabelsline as $key => $value ) { foreach ($extralabelsline as $key => $value) {
unset($_POST ["options_" . $key]); unset($_POST ["options_" . $key]);
} }
} }
@ -634,9 +631,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
$prodcustprice = new Productcustomerprice($db); $prodcustprice = new Productcustomerprice($db);
$filter = array ( $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->client->id);
't.fk_product' => $prod->id,'t.fk_soc' => $object->client->id
);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
if ($result) { if ($result) {
@ -818,7 +813,7 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa
// Unset extrafield // Unset extrafield
if (is_array($extralabelsline)) { if (is_array($extralabelsline)) {
// Get extra fields // Get extra fields
foreach ( $extralabelsline as $key => $value ) { foreach ($extralabelsline as $key => $value) {
unset($_POST ["options_" . $key]); unset($_POST ["options_" . $key]);
} }
} }
@ -1026,14 +1021,11 @@ else if ($action == 'down' && $user->rights->propal->creer) {
if (! $error) { if (! $error) {
// Actions on extra fields (by external module or standard code) // Actions on extra fields (by external module or standard code)
// FIXME le hook fait double emploi avec le trigger !! // FIXME le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array ( $hookmanager->initHooks(array('propaldao'));
'propaldao' $parameters = array('id' => $object->id);
)); $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been
$parameters = array ( // modified by
'id' => $object->id // some hooks
);
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by
// some hooks
if (empty($reshook)) { if (empty($reshook)) {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
if ($result < 0) { if ($result < 0) {
@ -1243,11 +1235,10 @@ if ($action == 'create') {
} }
// Other attributes // Other attributes
$parameters = array ( $parameters = array('colspan' => ' colspan="3"');
'colspan' => ' colspan="3"' $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified
); // by
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by // hook
// hook
if (empty($reshook) && ! empty($extrafields->attribute_label)) { if (empty($reshook) && ! empty($extrafields->attribute_label)) {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
} }
@ -1270,7 +1261,7 @@ if ($action == 'create') {
print '<td><input type="radio" name="createmode" value="copy"></td>'; print '<td><input type="radio" name="createmode" value="copy"></td>';
print '<td>' . $langs->trans("CopyPropalFrom") . ' </td>'; print '<td>' . $langs->trans("CopyPropalFrom") . ' </td>';
print '<td>'; print '<td>';
$liste_propal = array (); $liste_propal = array();
$liste_propal [0] = ''; $liste_propal [0] = '';
$sql = "SELECT p.rowid as id, p.ref, s.nom"; $sql = "SELECT p.rowid as id, p.ref, s.nom";
@ -1285,7 +1276,7 @@ if ($action == 'create') {
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ( $i < $num ) { while ($i < $num) {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
$propalRefAndSocName = $row [1] . " - " . $row [2]; $propalRefAndSocName = $row [1] . " - " . $row [2];
$liste_propal [$row [0]] = $propalRefAndSocName; $liste_propal [$row [0]] = $propalRefAndSocName;
@ -1358,14 +1349,12 @@ if ($action == 'create') {
// Clone confirmation // Clone confirmation
if ($action == 'clone') { if ($action == 'clone') {
// Create an array for form // Create an array for form
$formquestion = array ( $formquestion = array(
// 'text' => $langs->trans("ConfirmClone"), // 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' =>
array ( // 1),
'type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)') array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)')));
)
);
// Paiement incomplet. On demande si motif = escompte ou autre // Paiement incomplet. On demande si motif = escompte ou autre
$formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ClonePropal'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ClonePropal'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
} }
@ -1414,11 +1403,10 @@ if ($action == 'create') {
} }
if (! $formconfirm) { if (! $formconfirm) {
$parameters = array ( $parameters = array('lineid' => $lineid);
'lineid' => $lineid $formconfirm = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified
); // by
$formconfirm = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by // hook
// hook
} }
// Print form confirm // Print form confirm
@ -1685,13 +1673,12 @@ if ($action == 'create') {
// Other attributes (TODO Move this into an include) // Other attributes (TODO Move this into an include)
$res = $object->fetch_optionals($object->id, $extralabels); $res = $object->fetch_optionals($object->id, $extralabels);
$parameters = array ( $parameters = array('colspan' => ' colspan="3"');
'colspan' => ' colspan="3"' $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified
); // by
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by // hook
// hook
if (empty($reshook) && ! empty($extrafields->attribute_label)) { if (empty($reshook) && ! empty($extrafields->attribute_label)) {
foreach ( $extrafields->attribute_label as $key => $label ) { foreach ($extrafields->attribute_label as $key => $label) {
if ($action == 'edit_extras') { if ($action == 'edit_extras') {
$value = (isset($_POST ["options_" . $key]) ? $_POST ["options_" . $key] : $object->array_options ["options_" . $key]); $value = (isset($_POST ["options_" . $key]) ? $_POST ["options_" . $key] : $object->array_options ["options_" . $key]);
} else { } else {
@ -1705,9 +1692,7 @@ if ($action == 'create') {
print ' class="fieldrequired"'; print ' class="fieldrequired"';
print '>' . $label . '</td><td colspan="5">'; print '>' . $label . '</td><td colspan="5">';
// Convert date into timestamp format // Convert date into timestamp format
if (in_array($extrafields->attribute_type [$key], array ( if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) {
'date','datetime'
))) {
$value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]); $value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]);
} }
@ -1829,9 +1814,10 @@ if ($action == 'create') {
} }
} }
$parameters = array (); $parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been
// by hook // modified
// by hook
} }
} }
@ -1875,9 +1861,9 @@ if ($action == 'create') {
if ($action != 'presend') { if ($action != 'presend') {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
$parameters = array (); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook // modified by hook
if (empty($reshook)) { if (empty($reshook)) {
if ($action != 'statut' && $action != 'editline') { if ($action != 'statut' && $action != 'editline') {
// Validate // Validate
@ -1888,7 +1874,8 @@ if ($action == 'create') {
} }
// Create event // Create event
if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a
// "workflow" action so should appears somewhere else on // "workflow" action so should appears somewhere
// else on
// page. // page.
{ {
print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/fiche.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddAction") . '</a>'; print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/fiche.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddAction") . '</a>';
@ -2042,8 +2029,8 @@ if ($action == 'create') {
$formmail->fromname = $user->getFullName($langs); $formmail->fromname = $user->getFullName($langs);
$formmail->frommail = $user->email; $formmail->frommail = $user->email;
$formmail->withfrom = 1; $formmail->withfrom = 1;
$liste = array (); $liste = array();
foreach ( $object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value ) foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value)
$liste [$key] = $value; $liste [$key] = $value;
$formmail->withto = GETPOST("sendto") ? GETPOST("sendto") : $liste; $formmail->withto = GETPOST("sendto") ? GETPOST("sendto") : $liste;
$formmail->withtocc = $liste; $formmail->withtocc = $liste;
@ -2067,11 +2054,11 @@ if ($action == 'create') {
// Find the good contact adress // Find the good contact adress
$custcontact = ''; $custcontact = '';
$contactarr = array (); $contactarr = array();
$contactarr = $object->liste_contact(- 1, 'external'); $contactarr = $object->liste_contact(- 1, 'external');
if (is_array($contactarr) && count($contactarr) > 0) { if (is_array($contactarr) && count($contactarr) > 0) {
foreach ( $contactarr as $contact ) { foreach ($contactarr as $contact) {
if ($contact ['libelle'] == $langs->trans('TypeContact_propal_external_CUSTOMER')) { if ($contact ['libelle'] == $langs->trans('TypeContact_propal_external_CUSTOMER')) {
$contactstatic = new Contact($db); $contactstatic = new Contact($db);
$contactstatic->fetch($contact ['id']); $contactstatic->fetch($contact ['id']);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -18,183 +18,176 @@
*/ */
/** /**
* \file htdocs/product/ajax/products.php * \file htdocs/product/ajax/products.php
* \brief File to return Ajax response on product list request * \brief File to return Ajax response on product list request
*/ */
if (! defined('NOTOKENRENEWAL'))
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal define('NOTOKENRENEWAL', 1); // Disables token renewal
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREMENU'))
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); define('NOREQUIREMENU', '1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIREHTML'))
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); define('NOREQUIREHTML', '1');
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); if (! defined('NOREQUIREAJAX'))
if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); define('NOREQUIREAJAX', '1');
if (! defined('NOREQUIRESOC'))
define('NOREQUIRESOC', '1');
if (! defined('NOCSRFCHECK'))
define('NOCSRFCHECK', '1');
if (empty($_GET ['keysearch']) && ! defined('NOREQUIREHTML'))
define('NOREQUIREHTML', '1');
require '../../main.inc.php'; require '../../main.inc.php';
$htmlname=GETPOST('htmlname','alpha'); $htmlname = GETPOST('htmlname', 'alpha');
$socid=GETPOST('socid','int'); $socid = GETPOST('socid', 'int');
$type=GETPOST('type','int'); $type = GETPOST('type', 'int');
$mode=GETPOST('mode','int'); $mode = GETPOST('mode', 'int');
$status=((GETPOST('status','int') >= 0) ? GETPOST('status','int') : -1); $status = ((GETPOST('status', 'int') >= 0) ? GETPOST('status', 'int') : - 1);
$outjson=(GETPOST('outjson','int') ? GETPOST('outjson','int') : 0); $outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0);
$price_level=GETPOST('price_level','int'); $price_level = GETPOST('price_level', 'int');
$action=GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$id=GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$price_by_qty_rowid=GETPOST('pbq', 'int'); $price_by_qty_rowid = GETPOST('pbq', 'int');
/* /*
* View * View
*/ */
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n"; // print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
dol_syslog(join(',',$_GET)); dol_syslog(join(',', $_GET));
//print_r($_GET); // print_r($_GET);
if (! empty($action) && $action == 'fetch' && ! empty($id)) if (! empty($action) && $action == 'fetch' && ! empty($id)) {
{
require DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; require DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
$outjson=array(); $outjson = array();
$object = new Product($db); $object = new Product($db);
$ret=$object->fetch($id); $ret = $object->fetch($id);
if ($ret > 0) if ($ret > 0) {
{ $outref = $object->ref;
$outref=$object->ref; $outlabel = $object->label;
$outlabel=$object->label; $outdesc = $object->description;
$outdesc=$object->description; $outtype = $object->type;
$outtype=$object->type; $outqty = 1;
$outqty=1; $outdiscount = 0;
$outdiscount=0;
$found = false;
$found=false;
// Price by qty // Price by qty
if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a particular price related to qty if (! empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a
// particular price related
// to qty
{ {
$sql = "SELECT price, unitprice, quantity, remise_percent"; $sql = "SELECT price, unitprice, quantity, remise_percent";
$sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty "; $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty ";
$sql.= " WHERE rowid=".$price_by_qty_rowid.""; $sql .= " WHERE rowid=" . $price_by_qty_rowid . "";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
if ($objp) if ($objp) {
{ $found = true;
$found=true; $outprice_ht = price($objp->unitprice);
$outprice_ht=price($objp->unitprice); $outprice_ttc = price($objp->unitprice * (1 + ($object->tva_tx / 100)));
$outprice_ttc=price($objp->unitprice * (1 + ($object->tva_tx / 100))); $outpricebasetype = $object->price_base_type;
$outpricebasetype=$object->price_base_type; $outtva_tx = $object->tva_tx;
$outtva_tx=$object->tva_tx; $outqty = $objp->quantity;
$outqty=$objp->quantity; $outdiscount = $objp->remise_percent;
$outdiscount=$objp->remise_percent;
} }
} }
} }
// Multiprice // Multiprice
if (! $found && isset($price_level) && $price_level >= 1 && (! empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price level (from 1 to 6) if (! $found && isset($price_level) && $price_level >= 1 && (! empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price
// level (from 1 to 6)
{ {
$sql = "SELECT price, price_ttc, price_base_type, tva_tx"; $sql = "SELECT price, price_ttc, price_base_type, tva_tx";
$sql.= " FROM ".MAIN_DB_PREFIX."product_price "; $sql .= " FROM " . MAIN_DB_PREFIX . "product_price ";
$sql.= " WHERE fk_product='".$id."'"; $sql .= " WHERE fk_product='" . $id . "'";
$sql.= " AND entity IN (".getEntity('productprice', 1).")"; $sql .= " AND entity IN (" . getEntity('productprice', 1) . ")";
$sql.= " AND price_level=".$price_level; $sql .= " AND price_level=" . $price_level;
$sql.= " ORDER BY date_price"; $sql .= " ORDER BY date_price";
$sql.= " DESC LIMIT 1"; $sql .= " DESC LIMIT 1";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
if ($objp) if ($objp) {
{ $found = true;
$found=true; $outprice_ht = price($objp->price);
$outprice_ht=price($objp->price); $outprice_ttc = price($objp->price_ttc);
$outprice_ttc=price($objp->price_ttc); $outpricebasetype = $objp->price_base_type;
$outpricebasetype=$objp->price_base_type; $outtva_tx = $objp->tva_tx;
$outtva_tx=$objp->tva_tx;
} }
} }
} }
//Price by customer // Price by customer
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && ! empty($socid)) {
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
$prodcustprice = new Productcustomerprice ( $db ); $prodcustprice = new Productcustomerprice($db);
$filter = array ( $filter = array('t.fk_product' => $object->id,'t.fk_soc' => $socid);
't.fk_product' => $object->id,
't.fk_soc'=> $socid $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
); if ($result) {
if (count($prodcustprice->lines) > 0) {
$result = $prodcustprice->fetch_all ( '', '', 0,0, $filter ); $found = true;
if ($result) $outprice_ht = price($prodcustprice->lines [0]->price);
{ $outprice_ttc = price($prodcustprice->lines [0]->price_ttc);
if (count($prodcustprice->lines)>0) $outpricebasetype = $prodcustprice->lines [0]->price_base_type;
{ $outtva_tx = $prodcustprice->lines [0]->tva_tx;
$found=true;
$outprice_ht=price($prodcustprice->lines[0]->price);
$outprice_ttc=price($prodcustprice->lines[0]->price_ttc);
$outpricebasetype=$prodcustprice->lines[0]->price_base_type;
$outtva_tx=$prodcustprice->lines[0]->tva_tx;
} }
} }
} }
if (! $found) {
if (! $found) $outprice_ht = price($object->price);
{ $outprice_ttc = price($object->price_ttc);
$outprice_ht=price($object->price); $outpricebasetype = $object->price_base_type;
$outprice_ttc=price($object->price_ttc); $outtva_tx = $object->tva_tx;
$outpricebasetype=$object->price_base_type;
$outtva_tx=$object->tva_tx;
} }
$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); $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); echo json_encode($outjson);
} else {
} require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
else
{
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$langs->load("products"); $langs->load("products");
$langs->load("main"); $langs->load("main");
top_httphead(); top_httphead();
if (empty($htmlname)) return; if (empty($htmlname))
return;
$match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET));
$match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET));
sort($match); sort($match);
$idprod = (! empty($match[0]) ? $match[0] : ''); $idprod = (! empty($match [0]) ? $match [0] : '');
if (! GETPOST($htmlname) && ! GETPOST($idprod)) return; 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):'')); // 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); $form = new Form($db);
if (empty($mode) || $mode == 1) if (empty($mode) || $mode == 1) {
{ $arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, 2, $outjson, $socid);
$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);
} }
elseif ($mode == 2)
{
$arrayresult=$form->select_produits_fournisseurs_list($socid,"",$htmlname,$type,"",$searchkey,$status,$outjson,$socid);
}
$db->close(); $db->close();
if ($outjson) print json_encode($arrayresult); if ($outjson)
print json_encode($arrayresult);
} }
?> ?>

File diff suppressed because it is too large Load Diff