Fix no picot if no warehouse set

Fix search on warehouse
This commit is contained in:
Laurent Destailleur 2016-01-08 23:54:40 +01:00
parent a0d11e157b
commit 99f3870ee6
7 changed files with 49 additions and 34 deletions

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
@ -1056,7 +1056,7 @@ if ($action == 'create')
print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans("Draft").'</td></tr>';
// Description (must be a textarea and not html must be allowed (used in list view)
print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
print '<td>';
print '<textarea name="description" cols="80" rows="'.ROWS_3.'">'.GETPOST('description').'</textarea>';
print '</td></tr>';
@ -1068,7 +1068,7 @@ if ($action == 'create')
$langs->load("project");
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
print '<tr><td>'.$langs->trans("Project").'</td><td>';
/* Fix: If a project must be linked to any companies (suppliers or not), project must be not be set as limited to customer but must be not linked to any particular thirdparty
if ($societe->fournisseur==1)
$numprojet=select_projects(-1,$_POST["projectid"],'projectid');
@ -1087,7 +1087,7 @@ if ($action == 'create')
if ($conf->contrat->enabled)
{
$langs->load("contracts");
print '<tr><td valign="top">'.$langs->trans("Contract").'</td><td>';
print '<tr><td>'.$langs->trans("Contract").'</td><td>';
$numcontrat=$formcontract->select_contract($soc->id,GETPOST('contratid','int'),'contratid',0,1);
if ($numcontrat==0)
{
@ -1106,19 +1106,19 @@ if ($action == 'create')
// Public note
print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>';
print '<td valign="top" colspan="2">';
print '<td tdtop">'.$langs->trans('NotePublic').'</td>';
print '<td colspan="2">';
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
print $doleditor->Create(1);
//print '<textarea name="note_public" cols="80" rows="'.ROWS_3.'">'.$note_public.'</textarea>';
print '</td></tr>';
// Private note
if (!empty($user->societe_id))
if (empty($user->societe_id))
{
print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
print '<td valign="top" colspan="2">';
print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
print '<td colspan="2">';
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
print $doleditor->Create(1);
//print '<textarea name="note_private" cols="80" rows="'.ROWS_3.'">'.$note_private.'</textarea>';
@ -1278,7 +1278,7 @@ else if ($id > 0 || ! empty($ref))
}
// Description (must be a textarea and not html must be allowed (used in list view)
print '<tr><td valign="top">';
print '<tr><td>';
print $form->editfieldkey("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea');
print '</td><td colspan="3">';
print $form->editfieldval("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea:8:80');

View File

@ -861,7 +861,7 @@ else
// Description (used in invoice, propal...)
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
$doleditor = new DolEditor('desc', GETPOST('desc'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80);
$doleditor = new DolEditor('desc', GETPOST('desc'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, '80%');
$doleditor->Create();
print "</td></tr>";
@ -965,7 +965,7 @@ else
print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">';
// We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF.
$doleditor = new DolEditor('note', GETPOST('note'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 8, 70);
$doleditor = new DolEditor('note', GETPOST('note'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 8, '80%');
$doleditor->Create();
print "</td></tr>";

View File

@ -222,10 +222,7 @@ else
// multilang
if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$langs->getDefaultLang() ."'";
$sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')';
if ($sall)
{
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
}
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
// if the type is not 1, we show all products (type = 0,2,3)
if (dol_strlen($type))
{

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
@ -350,8 +350,11 @@ if ($resql)
// Warehouse
print '<td>';
$warehousetmp->fetch($objp->fk_entrepot);
print $warehousetmp->getNomUrl(1);
if ($objp->fk_entrepot > 0)
{
$warehousetmp->fetch($objp->fk_entrepot);
print $warehousetmp->getNomUrl(1);
}
print '</td>';
print '<td align="center">'.$objp->batch.'</td>';
print '<td align="center">'.dol_print_date($db->jdate($objp->eatby), 'day').'</td>';

View File

@ -192,7 +192,7 @@ if ($action == 'create')
print '<tr><td >'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.(!empty($object->lieu)?$object->lieu:'').'"></td></tr>';
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">';
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
// Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('desc',(!empty($object->description)?$object->description:''),'',180,'dolibarr_notes','In',false,true,$conf->fckeditor->enabled,5,70);
@ -270,7 +270,7 @@ else
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$object->lieu.'</td></tr>';
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($object->description).'</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($object->description).'</td></tr>';
// Address
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3">';
@ -298,17 +298,17 @@ else
$calcproducts=$object->nb_products();
// Total nb of different products
print '<tr><td valign="top">'.$langs->trans("NumberOfDifferentProducts").'</td><td colspan="3">';
print '<tr><td>'.$langs->trans("NumberOfDifferentProducts").'</td><td colspan="3">';
print empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb'];
print "</td></tr>";
// Nb of products
print '<tr><td valign="top">'.$langs->trans("NumberOfProducts").'</td><td colspan="3">';
print '<tr><td>'.$langs->trans("NumberOfProducts").'</td><td colspan="3">';
print empty($calcproducts['nb'])?'0':$calcproducts['nb'];
print "</td></tr>";
// Value
print '<tr><td valign="top">'.$langs->trans("EstimatedStockValueShort").'</td><td colspan="3">';
print '<tr><td>'.$langs->trans("EstimatedStockValueShort").'</td><td colspan="3">';
print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency);
print "</td></tr>";
@ -326,7 +326,7 @@ else
{
dol_print_error($db);
}
print '<tr><td valign="top">'.$langs->trans("LastMovement").'</td><td colspan="3">';
print '<tr><td>'.$langs->trans("LastMovement").'</td><td colspan="3">';
if ($lastmovementdate)
{
print dol_print_date($lastmovementdate,'dayhour').' ';
@ -529,10 +529,10 @@ else
// Ref
print '<tr><td width="20%" class="fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input name="libelle" size="20" value="'.$object->libelle.'"></td></tr>';
print '<tr><td width="20%">'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.$object->lieu.'"></td></tr>';
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.$object->lieu.'"></td></tr>';
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">';
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
// Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('desc',$object->description,'',180,'dolibarr_notes','In',false,true,$conf->fckeditor->enabled,5,70);
@ -551,12 +551,12 @@ else
print '</td></tr>';
// Country
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td colspan="3">';
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
print $form->select_country($object->country_id?$object->country_id:$mysoc->country_code,'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '</td></tr>';
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td colspan="3">';
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
print '<select name="statut" class="flat">';
print '<option value="0" '.($object->statut == 0?'selected':'').'>'.$langs->trans("WarehouseClosed").'</option>';
print '<option value="1" '.($object->statut == 0?'':'selected').'>'.$langs->trans("WarehouseOpened").'</option>';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
@ -57,8 +57,7 @@ print '<table class="noborder nohover" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td colspan="3">'.$langs->trans("Search").'</td></tr>';
print "<tr ".$bc[false]."><td>";
print $langs->trans("Ref").':</td><td><input class="flat" type="text" size="18" name="sref"></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print "<tr ".$bc[false]."><td>".$langs->trans("Other").':</td><td><input type="text" name="sall" class="flat" size="18"></td>';
print $langs->trans("Warehouse").':</td><td><input class="flat" type="text" size="18" name="sall"></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print "</table></form><br>";
$sql = "SELECT e.label, e.rowid, e.statut";

View File

@ -48,6 +48,17 @@ $offset = $limit * $page;
$year = strftime("%Y",time());
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
'e.label'=>"Ref",
'e.lieu'=>"LocationSummary",
'e.description'=>"Description",
'e.address'=>"Address",
'e.zip'=>'Zip',
'e.town'=>'Town',
);
/*
* View
@ -62,11 +73,10 @@ $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";
$sql.= " WHERE e.entity IN (".getEntity('stock', 1).")";
if ($search_ref) $sql.= natural_search("e.label", $search_ref); // ref
if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label
if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status;
if ($sall) $sql.= natural_search(array('e.label','e.description','e.lieu','e.address','e.town'), $sall);
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
$sql.= " GROUP BY e.rowid, e.label, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays";
$totalnboflines=0;
$result=$db->query($sql);
@ -95,6 +105,12 @@ if ($result)
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
if ($sall)
{
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
}
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";