Quelques amlioration sur fonction selection produit ajax:
Look: On supprime espace encombrant sous la liste. Fix: Correction problme de gestion des accents Fix: Produits en doubles selon activation et droits de categories New: Affiche message si aucun lment trouv Look: Agrandissement zone de saisie
This commit is contained in:
parent
7174e0a5f1
commit
e21c82d60b
@ -25,8 +25,19 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require('./pre.inc.php');
|
||||
require('./main.inc.php');
|
||||
|
||||
$langs->load("products");
|
||||
|
||||
//header("Content-type: text/html; charset=UTF-8");
|
||||
header("Content-type: text/html; charset=iso-8859-1");
|
||||
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
|
||||
print "\n<html>";
|
||||
print "\n<body>";
|
||||
|
||||
$form = new Form($db);
|
||||
$form->select_produits_do("",$_GET["htmlname"],"","",$_GET["price_level"],$_GET["keyref"],$_GET["keylabel"]);
|
||||
|
||||
|
||||
print "</body>";
|
||||
print "</html>";
|
||||
?>
|
||||
|
||||
@ -1236,7 +1236,7 @@ if ($_GET['propalid'] > 0)
|
||||
{
|
||||
$html->select_produits('','idprod','',$conf->produit->limit_size);
|
||||
}
|
||||
print '<br>';
|
||||
if (! $conf->use_ajax) print '<br>';
|
||||
print '<textarea cols="50" name="np_desc" rows="'.ROWS_2.'"></textarea>';
|
||||
print '</td>';
|
||||
print '<td> </td>';
|
||||
|
||||
@ -704,20 +704,16 @@ class Form
|
||||
if($conf->use_ajax)
|
||||
{
|
||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/lib/prototype.js"></script>';
|
||||
print $langs->trans("Ref").'<input type="text" size="5" name="ajkeyref'.$htmlname.'" id="ajkeyref'.$htmlname.'"> ';
|
||||
print $langs->trans("Label").'<input type="text" size="5" name="ajkeylabel'.$htmlname.'" id="ajkeylabel'.$htmlname.'">';
|
||||
print $langs->trans("Ref").':<input type="text" size="8" name="ajkeyref'.$htmlname.'" id="ajkeyref'.$htmlname.'"> ';
|
||||
print $langs->trans("Label").':<input type="text" size="16" name="ajkeylabel'.$htmlname.'" id="ajkeylabel'.$htmlname.'">';
|
||||
print '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="">';
|
||||
print '<script type="text/javascript">';
|
||||
print 'var url = \''.DOL_URL_ROOT.'/ajaxresponse.php\';';
|
||||
print 'new Form.Element.Observer($("ajkeyref'.$htmlname.'"), 1, function(){var myAjax = new Ajax.Updater( {success: \'ajdynfield'.$htmlname.'\'}, url, {method: \'get\', parameters: "keyref="+$("ajkeyref'.$htmlname.'").value+"&htmlname='.$htmlname.'&price_level='.$price_level.'"});});';
|
||||
print 'new Form.Element.Observer($("ajkeylabel'.$htmlname.'"), 1, function(){var myAjax = new Ajax.Updater( {success: \'ajdynfield'.$htmlname.'\'}, url, {method: \'get\', parameters: "keylabel="+$("ajkeylabel'.$htmlname.'").value+"&htmlname='.$htmlname.'&price_level='.$price_level.'"});});';
|
||||
print 'function publish_selvalue(obj){$("'.$htmlname.'").value = obj.options[obj.selectedIndex].value;}';
|
||||
print '</script>';
|
||||
print '<script type="text/javascript">';
|
||||
print 'var url = \''.DOL_URL_ROOT.'/ajaxresponse.php\';';
|
||||
print 'new Form.Element.Observer($("ajkeylabel'.$htmlname.'"), 1, function(){var myAjax = new Ajax.Updater( {success: \'ajdynfield'.$htmlname.'\'}, url, {method: \'get\', parameters: "keylabel="+$("ajkeylabel'.$htmlname.'").value+"&htmlname='.$htmlname.'&price_level='.$price_level.'"});});';
|
||||
print '</script>';
|
||||
print '<div id="ajdynfield'.$htmlname.'">';
|
||||
print '</div>';
|
||||
print '<div class="notopnoleftnoright" id="ajdynfield'.$htmlname.'"></div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -736,16 +732,22 @@ class Form
|
||||
function select_produits_do($selected='',$htmlname='productid',$filtretype='',$limit=20,$price_level=0,$ajaxkeyref='',$ajaxkeylabel='')
|
||||
{
|
||||
global $langs,$conf,$user;
|
||||
|
||||
$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p ";
|
||||
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
|
||||
$user->getrights("categorie");
|
||||
|
||||
$sql = "SELECT ";
|
||||
if ($conf->categorie->enabled && ! $user->rights->categorie->voir)
|
||||
{
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
|
||||
$sql.="DISTINCT";
|
||||
}
|
||||
$sql.= " p.rowid, p.label, p.ref, p.price, p.duration";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p ";
|
||||
if ($conf->categorie->enabled && ! $user->rights->categorie->voir)
|
||||
{
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
|
||||
}
|
||||
$sql.= " WHERE p.envente = 1";
|
||||
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
|
||||
if ($conf->categorie->enabled && ! $user->rights->categorie->voir)
|
||||
{
|
||||
$sql.= ' AND IFNULL(c.visible,1)=1';
|
||||
}
|
||||
@ -755,48 +757,61 @@ class Form
|
||||
$sql.= " ORDER BY p.nbvente DESC";
|
||||
if ($limit) $sql.= " LIMIT $limit";
|
||||
|
||||
$result=$this->db->query($sql);
|
||||
if (! $result) dolibarr_print_error($this->db);
|
||||
|
||||
// Multilang : on construit une liste des traductions des produits listés
|
||||
$sqld = "SELECT d.fk_product, d.label";
|
||||
$sqld.= " FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_det as d ";
|
||||
$sqld.= " WHERE d.fk_product=p.rowid AND p.envente=1 AND d.lang='". $langs->getDefaultLang() ."'";
|
||||
$sqld.= " ORDER BY p.nbvente DESC";
|
||||
|
||||
// inutile de faire la requete si l'option n'est pas active
|
||||
if ($conf->global->MAIN_MULTILANGS)
|
||||
{
|
||||
$resultd = $this->db->query($sqld);
|
||||
if ( $resultd ) $objtp = $this->db->fetch_object($resultd);
|
||||
}
|
||||
$result=$this->db->query($sql);
|
||||
if (! $result) dolibarr_print_error($this->db);
|
||||
|
||||
// Multilang : on construit une liste des traductions des produits listés
|
||||
if ($conf->global->MAIN_MULTILANGS)
|
||||
{
|
||||
$sqld = "SELECT d.fk_product, d.label";
|
||||
$sqld.= " FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_det as d ";
|
||||
$sqld.= " WHERE d.fk_product=p.rowid AND p.envente=1 AND d.lang='". $langs->getDefaultLang() ."'";
|
||||
$sqld.= " ORDER BY p.nbvente DESC";
|
||||
$resultd = $this->db->query($sqld);
|
||||
if ( $resultd ) $objtp = $this->db->fetch_object($resultd);
|
||||
}
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if($conf->use_ajax)
|
||||
print '<select class="flat" name="'.$htmlname.'" onchange="publish_selvalue(this);">';
|
||||
else
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
print "<option value=\"0\" selected=\"true\"> </option>";
|
||||
|
||||
$num = $this->db->num_rows($result);
|
||||
|
||||
if ($conf->use_ajax)
|
||||
{
|
||||
if (! $num)
|
||||
{
|
||||
print $langs->trans("NoProductMatching").' ';
|
||||
}
|
||||
// else
|
||||
// {
|
||||
print '<select class="flat" name="'.$htmlname.'" onchange="publish_selvalue(this);">';
|
||||
print "<option value=\"0\" selected=\"true\"> </option>";
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
print "<option value=\"0\" selected=\"true\"> </option>";
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
// Multilangs : modification des donnée si une traduction existe
|
||||
// Multilangs : modification des donnée si une traduction existe
|
||||
if ($conf->global->MAIN_MULTILANGS)
|
||||
{
|
||||
if ( $objp->rowid == $objtp->fk_product ) // si on a une traduction
|
||||
{
|
||||
if ( $objtp->label != '') $objp->label = $objtp->label;
|
||||
if ( $resultd ) $objtp = $this->db->fetch_object($resultd); // on charge la traduction suivante
|
||||
}
|
||||
$opt = '<option value="'.$objp->rowid.'">'.$objp->ref.' - ';
|
||||
$opt.= dolibarr_trunc($objp->label,32).' - ';
|
||||
}
|
||||
$opt = '<option value="'.$objp->rowid.'">'.$objp->ref.' - ';
|
||||
$opt.= dolibarr_trunc($objp->label,32).' - ';
|
||||
|
||||
//multiprix
|
||||
if($price_level > 1)
|
||||
// Multiprix
|
||||
if ($price_level > 1)
|
||||
{
|
||||
$sql= "SELECT price ";
|
||||
$sql.= "FROM ".MAIN_DB_PREFIX."product_price ";
|
||||
@ -816,8 +831,17 @@ class Form
|
||||
print $opt;
|
||||
$i++;
|
||||
}
|
||||
print '</select>';
|
||||
|
||||
if ($conf->use_ajax)
|
||||
{
|
||||
// if ($num)
|
||||
// {
|
||||
print '</select>';
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
print '</select>';
|
||||
}
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
|
||||
@ -122,7 +122,7 @@ class modUser extends DolibarrModules
|
||||
$this->rights[$r][2] = 'w';
|
||||
$this->rights[$r][3] = 1;
|
||||
$this->rights[$r][4] = 'self';
|
||||
$this->rights[$r][5] = 'supprimer';
|
||||
$this->rights[$r][5] = 'creer';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 256;
|
||||
|
||||
@ -58,6 +58,8 @@ ContractStatusToRun=A mettre en service
|
||||
ContractNotRunning=This contract is not running
|
||||
ErrorProductAlreadyExists=A product with reference %s already exists.
|
||||
ErrorProductBadRefOrLabel=Wrong value for reference or label.
|
||||
Suppliers=Suppliers
|
||||
SupplierRef=Supplier ref.
|
||||
ShowProduct=Show product
|
||||
ShowService=Show service
|
||||
ProductsAndServicesArea=Product and Services area
|
||||
@ -66,12 +68,18 @@ AddToOtherProposals=Add to other proposals
|
||||
AddToMyBills=Add to my bills
|
||||
AddToOtherBills=Add to other bills
|
||||
CorrectStock=Correct stock
|
||||
AddPhoto=Add photo
|
||||
ListOfStockMovements=List of stock movements
|
||||
NoPhotoYet=No pictures available yet
|
||||
BuiingPrice=Buying price
|
||||
SupplierCard=Supplier card
|
||||
CommercialCard=Commercial card
|
||||
AllWays=Path to find your product in stock
|
||||
NoCat=Your product is not in any category
|
||||
PrimaryWay=Primary path
|
||||
DeleteFromCat=Remove from category
|
||||
PriceRemoved=Price removed
|
||||
BarCode=Barcode
|
||||
Pack=Pack
|
||||
Packs=Packs
|
||||
NoteNotVisibleOnBill=Note (not visible on invoices, proposals...)
|
||||
CreateCopy=Create copy
|
||||
ServiceLimitedDuration=If produced of service type at limited duration:
|
||||
@ -89,9 +97,12 @@ ProductToAddSearch=Search product to add
|
||||
AddDel=Add/Delete
|
||||
Quantity=Quantity
|
||||
NoMatchFound=No match found
|
||||
ProductAssociationList=List of related products/services: name of product/service (quantity affected)
|
||||
ErrorAssociationIsFatherOfThis=One of selected product is parent with current product
|
||||
DeleteProduct=Delete a product/service
|
||||
ConfirmDeleteProduct=Are you sure you want to delete this product/service?
|
||||
ProductDeleted=Product/Service "%s" deleted from database.
|
||||
ExportDataset_produit_1=Products and services
|
||||
DeleteProductLine=Delete product line
|
||||
ConfirmDeleteProductLine=Are you sure you want to delete this product line?
|
||||
ConfirmDeleteProductLine=Are you sure you want to delete this product line?
|
||||
NoProductMatching=No product/service match your criteria
|
||||
@ -5,6 +5,7 @@ GroupCard=Group card
|
||||
NoContactCard=No card among contacts
|
||||
Permission=Permission
|
||||
Permissions=Permissions
|
||||
EditPassword=Edit password
|
||||
SendNewPassword=Send new password
|
||||
ReinitPassword=Generate new password
|
||||
PasswordChangedTo=Password changed to: %s
|
||||
|
||||
@ -59,7 +59,7 @@ ContractNotRunning=Ce contrat n'est pas en service
|
||||
ErrorProductAlreadyExists=Un produit avec la référence %s existe déjà.
|
||||
ErrorProductBadRefOrLabel=La valeur de la reference ou du libellé est incorrecte.
|
||||
Suppliers=Fournisseurs
|
||||
SupplierRef=Référence fournisseur
|
||||
SupplierRef=Réf. fournisseur
|
||||
ShowProduct=Afficher produit
|
||||
ShowService=Afficher service
|
||||
ProductsAndServicesArea=Espace Produit et Services
|
||||
@ -104,4 +104,5 @@ ConfirmDeleteProduct=Etes-vous s
|
||||
ProductDeleted=Le produit/service "%s" à été supprimé de la base.
|
||||
ExportDataset_produit_1=Produits et services
|
||||
DeleteProductLine=Supprimer ligne produit
|
||||
ConfirmDeleteProductLine=Êtes-vous sûr de vouloir effacer cette ligne produit ?
|
||||
ConfirmDeleteProductLine=Êtes-vous sûr de vouloir effacer cette ligne produit ?
|
||||
NoProductMatching=Aucun produit/service ne répond au critère
|
||||
@ -5,6 +5,7 @@ GroupCard=Fiche groupe
|
||||
NoContactCard=Pas de fiche parmi les contacts
|
||||
Permission=Droit
|
||||
Permissions=Droits
|
||||
EditPassword=Modifier mot de passe
|
||||
SendNewPassword=Envoyer nouveau mot de passe
|
||||
ReinitPassword=Générer nouveau mot de passe
|
||||
PasswordChangedTo=Mot de passe modifié en: %s
|
||||
|
||||
Loading…
Reference in New Issue
Block a user