Skip to content
Snippets Groups Projects
Commit cd9a893b authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: disable warehouse

parent 211b47f4
Branches
No related tags found
No related merge requests found
...@@ -29,24 +29,26 @@ $langs->load("@cashdesk"); ...@@ -29,24 +29,26 @@ $langs->load("@cashdesk");
// Verification // Verification
if ( strlen ($_GET["code"]) >= 0 ) // If at least one key if ( strlen ($_GET["code"]) >= 0 ) // If at least one key
{ {
$request="SELECT p.rowid, p.ref, p.label, p.tva_tx $sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx";
FROM ".MAIN_DB_PREFIX."product as p $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product";
WHERE p.envente = 1 $sql.= " WHERE p.envente = 1";
AND p.fk_product_type = 0"; $sql.= " AND p.fk_product_type = 0";
if ($conf->stock->enabled) $request.=" AND ps.fk_entrepot = '".$conf_fkentrepot."'"; if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.=" AND ps.fk_entrepot = '".$conf_fkentrepot."'";
$request.=" AND (p.ref LIKE '%".$_GET['code']."%' $sql.= " AND (p.ref LIKE '%".$_GET['code']."%' OR p.label LIKE '%".$_GET['code']."%')";
OR p.label LIKE '%".$_GET['code']."%') $sql.= " ORDER BY label";
ORDER BY label";
dol_syslog($request);
$res = $db->query ($request);
if ( $nbr = $db->num_rows($res) ) { dol_syslog($sql);
$result = $db->query($sql);
if ($result)
{
if ( $nbr = $db->num_rows($result) )
{
$resultat = '<ul class="dhtml_bloc">'; $resultat = '<ul class="dhtml_bloc">';
$ret=array(); $i=0; $ret=array(); $i=0;
while ( $tab = $db->fetch_array($res) ) while ( $tab = $db->fetch_array($result) )
{ {
foreach ( $tab as $cle => $valeur ) foreach ( $tab as $cle => $valeur )
{ {
...@@ -56,28 +58,26 @@ if ( strlen ($_GET["code"]) >= 0 ) // If at least one key ...@@ -56,28 +58,26 @@ if ( strlen ($_GET["code"]) >= 0 ) // If at least one key
} }
$tab=$ret; $tab=$ret;
for ( $i = 0; $i < count ($tab); $i++ ) { for ( $i = 0; $i < count ($tab); $i++ )
{
$resultat .= ' $resultat .= '
<li class="dhtml_defaut" title="'.$tab[$i]['ref'].'" <li class="dhtml_defaut" title="'.$tab[$i]['ref'].'"
onMouseOver="javascript: this.className = \'dhtml_selection\';" onMouseOver="javascript: this.className = \'dhtml_selection\';"
onMouseOut="javascript: this.className = \'dhtml_defaut\';" onMouseOut="javascript: this.className = \'dhtml_defaut\';"
">'.htmlentities($tab[$i]['ref'].' - '.$tab[$i]['label']).'</li> ">'.htmlentities($tab[$i]['ref'].' - '.$tab[$i]['label']).'</li>
'; ';
} }
$resultat .= '</ul>'; $resultat .= '</ul>';
echo $resultat; print $resultat;
}
} else { else
echo (' {
<ul class="dhtml_bloc"> print '<ul class="dhtml_bloc">';
<li class="dhtml_defaut">'.$langs->trans("NoResults").'</li> print '<li class="dhtml_defaut">'.$langs->trans("NoResults").'</li>';
</ul> print '</ul>';
'); }
} }
} }
......
...@@ -25,88 +25,86 @@ $obj_facturation = unserialize ($_SESSION['serObjFacturation']); ...@@ -25,88 +25,86 @@ $obj_facturation = unserialize ($_SESSION['serObjFacturation']);
unset ($_SESSION['serObjFacturation']); unset ($_SESSION['serObjFacturation']);
switch ( $_GET['action'] ) { switch ( $_GET['action'] )
{
default: default:
if ( $_POST['hdnSource'] != 'NULL' ) { if ( $_POST['hdnSource'] != 'NULL' )
{
// Recuperation des donnees en fonction de la source (liste d�roulante ou champ texte) ... $sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx";
if ( $_POST['hdnSource'] == 'LISTE' ) { if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$res = $db->query('SELECT fk_product, ref, price, reel, tva_tx if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product";
FROM '.MAIN_DB_PREFIX.'product
LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product
WHERE fk_product = '.$_POST['selProduit'].'
;');
} else if ( $_POST['hdnSource'] == 'REF' ) {
$res = $db->query('SELECT fk_product, ref, price, reel, tva_tx
FROM '.MAIN_DB_PREFIX.'product
LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product
WHERE ref = \''.$_POST['txtRef'].'\'
;');
// Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ...
if ( $_POST['hdnSource'] == 'LISTE' )
{
$sql.= " WHERE p.rowid = ".$_POST['selProduit'];
} }
else if ( $_POST['hdnSource'] == 'REF' )
{
$sql.= " WHERE p.ref = '".$_POST['txtRef']."'";
}
if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " AND ps.fk_entrepot = ".$conf_fkentrepot;
$result = $db->query($sql);
if ($result)
{
// ... et enregistrement dans l'objet // ... et enregistrement dans l'objet
if ( $db->num_rows ($res) ) { if ( $db->num_rows ($result) )
{
$ret=array(); $ret=array();
$tab = $db->fetch_array($res); $tab = $db->fetch_array($result);
foreach ( $tab as $cle => $valeur ) foreach ( $tab as $key => $value )
{ {
$ret[$cle] = $valeur; $ret[$key] = $value;
} }
$tab = $ret;
$obj_facturation->id( $tab['fk_product'] ); $obj_facturation->id( $ret['rowid'] );
$obj_facturation->ref( $tab['ref'] ); $obj_facturation->ref( $ret['ref'] );
$obj_facturation->stock( $tab['reel']); $obj_facturation->stock( $ret['reel'] );
$obj_facturation->prix( $tab['price'] ); $obj_facturation->prix( $ret['price'] );
$obj_facturation->tva( $tab['tva_tx'] ); $obj_facturation->tva( $ret['tva_tx'] );
// Definition du filtre pour n'afficher que le produit concerne // Definition du filtre pour n'afficher que le produit concerne
if ( $_POST['hdnSource'] == 'LISTE' ) { if ( $_POST['hdnSource'] == 'LISTE' )
{
$filtre = $tab['ref']; $filtre = $ret['ref'];
}
} else if ( $_POST['hdnSource'] == 'REF' ) { else if ( $_POST['hdnSource'] == 'REF' )
{
$filtre = $_POST['txtRef'];; $filtre = $_POST['txtRef'];
} }
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&filtre='.$filtre; $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&filtre='.$filtre;
}
} else { else
{
$obj_facturation->raz(); $obj_facturation->raz();
if ( $_POST['hdnSource'] == 'REF' ) { if ( $_POST['hdnSource'] == 'REF' )
{
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&filtre='.$_POST['txtRef']; $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&filtre='.$_POST['txtRef'];
}
} else { else
{
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation'; $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
} }
} }
}
} else { else
{
dol_print_error($db);
}
}
else
{
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation'; $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
} }
break; break;
case 'ajout_article'; case 'ajout_article':
$obj_facturation->qte($_POST['txtQte']); $obj_facturation->qte($_POST['txtQte']);
$obj_facturation->tva($_POST['selTva']); $obj_facturation->tva($_POST['selTva']);
$obj_facturation->remise_percent($_POST['txtRemise']); $obj_facturation->remise_percent($_POST['txtRemise']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment