Standardize database: field ref of warehouse was renamed label -> ref

This commit is contained in:
Laurent Destailleur 2017-11-24 15:27:00 +01:00
parent 3db52b5f9e
commit 9f235e1ff6
17 changed files with 189 additions and 191 deletions

View File

@ -768,7 +768,7 @@ class Commande extends CommonOrder
$sql.= ", multicurrency_code"; $sql.= ", multicurrency_code";
$sql.= ", multicurrency_tx"; $sql.= ", multicurrency_tx";
$sql.= ")"; $sql.= ")";
$sql.= " VALUES ('(PROV)',".$this->socid.", '".$this->db->idate($now)."', ".$user->id; $sql.= " VALUES ('(PROV)', ".$this->socid.", '".$this->db->idate($now)."', ".$user->id;
$sql.= ", ".($this->fk_project>0?$this->fk_project:"null"); $sql.= ", ".($this->fk_project>0?$this->fk_project:"null");
$sql.= ", '".$this->db->idate($date)."'"; $sql.= ", '".$this->db->idate($date)."'";
$sql.= ", ".($this->source>=0 && $this->source != '' ?$this->db->escape($this->source):'null'); $sql.= ", ".($this->source>=0 && $this->source != '' ?$this->db->escape($this->source):'null');

View File

@ -2477,7 +2477,7 @@ else if ($id || $ref)
} }
// Create bill // Create bill
if (! empty($conf->facture->enabled) && $object->statut > 0) if (! empty($conf->facture->enabled) && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED))
{ {
if ($user->rights->facture->creer) if ($user->rights->facture->creer)
{ {
@ -2489,18 +2489,18 @@ else if ($id || $ref)
// This is just to generate a delivery receipt // This is just to generate a delivery receipt
//var_dump($object->linkedObjectsIds['delivery']); //var_dump($object->linkedObjectsIds['delivery']);
if ($conf->livraison_bon->enabled && ($object->statut == 1 || $object->statut == 2) && $user->rights->expedition->livraison->creer && count($object->linkedObjectsIds['delivery']) == 0) if ($conf->livraison_bon->enabled && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED) && $user->rights->expedition->livraison->creer && count($object->linkedObjectsIds['delivery']) == 0)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=create_delivery">'.$langs->trans("CreateDeliveryOrder").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=create_delivery">'.$langs->trans("CreateDeliveryOrder").'</a>';
} }
// Close // Close
if (! empty($conf->facture->enabled) && $object->statut > 0) if ($object->statut == Expedition::STATUS_VALIDATED)
{ {
if ($user->rights->expedition->creer && $object->statut > 0 && ! $object->billed) if ($user->rights->expedition->creer && $object->statut > 0 && ! $object->billed)
{ {
$label="Close"; $paramaction='classifyclosed'; // = Transferred/Received $label="Close"; $paramaction='classifyclosed'; // = Transferred/Received
// Label here should be "Close" or "ClassifyBilled" if we decided to make bill on shipments instead of orders // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on shipments instead of orders
if (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) // TODO Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close. if (! empty($conf->facture->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ?
{ {
$label="ClassifyBilled"; $label="ClassifyBilled";
$paramaction='classifybilled'; $paramaction='classifybilled';

View File

@ -68,6 +68,8 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer;
-- For 7.0 -- For 7.0
ALTER table llx_entrepot CHANGE COLUMN label ref varchar(255);
UPDATE llx_paiementfourn SET ref = rowid WHERE ref IS NULL; UPDATE llx_paiementfourn SET ref = rowid WHERE ref IS NULL;
UPDATE llx_paiementfourn SET entity = 1 WHERE entity IS NULL; UPDATE llx_paiementfourn SET entity = 1 WHERE entity IS NULL;

View File

@ -1,6 +1,6 @@
-- ============================================================================ -- ============================================================================
-- Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> -- Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> -- Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
-- --
-- This program is free software; you can redistribute it and/or modify -- This program is free software; you can redistribute it and/or modify
@ -21,9 +21,9 @@
create table llx_entrepot create table llx_entrepot
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
ref varchar(255) NOT NULL,
datec datetime, datec datetime,
tms timestamp, tms timestamp,
label varchar(255) NOT NULL,
entity integer DEFAULT 1 NOT NULL, -- multi company id entity integer DEFAULT 1 NOT NULL, -- multi company id
description text, description text,
lieu varchar(64), -- resume lieu situation lieu varchar(64), -- resume lieu situation

View File

@ -329,6 +329,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</table>'; print '</table>';
print '</div>'; print '</div>';
/* Second column
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
print '</table>';
print '</div>';*/
print '</div>'; print '</div>';
print '</div>'; print '</div>';
@ -359,7 +369,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
} }
/* /*
if ($user->rights->sellyoursaas->create) if ($user->rights->mymodule->create)
{ {
if ($object->status == 1) if ($object->status == 1)
{ {
@ -396,13 +406,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
// Documents // Documents
/*$comref = dol_sanitizeFileName($object->ref); /*$objref = dol_sanitizeFileName($object->ref);
$relativepath = $comref . '/' . $comref . '.pdf'; $relativepath = $comref . '/' . $comref . '.pdf';
$filedir = $conf->mymodule->dir_output . '/' . $comref; $filedir = $conf->mymodule->dir_output . '/' . $objref;
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
$genallowed = $user->rights->mymodule->read; // If you can read, you can build the PDF to read content $genallowed = $user->rights->mymodule->read; // If you can read, you can build the PDF to read content
$delallowed = $user->rights->mymodule->create; // If you can create/edit, you can remove a file on card $delallowed = $user->rights->mymodule->create; // If you can create/edit, you can remove a file on card
print $formfile->showdocuments('mymodule', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); print $formfile->showdocuments('mymodule', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
*/ */
// Show links to link elements // Show links to link elements
@ -426,13 +436,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</div></div></div>'; print '</div></div></div>';
} }
//Select mail models is same action as presend
/*
if (GETPOST('modelselected')) $action = 'presend';
// Presend form // Presend form
$modelmail='myobject'; $modelmail='inventory';
$defaulttopic='Information'; $defaulttopic='InformationMessage';
$diroutput = $conf->mymodule->dir_output; $diroutput = $conf->product->dir_output.'/inventory';
$trackid = 'myobject'.$object->id; $trackid = 'stockinv'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
*/
} }

View File

@ -87,7 +87,7 @@ class FormProduct
$warehouseStatus[] = Entrepot::STATUS_OPEN_INTERNAL; $warehouseStatus[] = Entrepot::STATUS_OPEN_INTERNAL;
} }
$sql = "SELECT e.rowid, e.label, e.description, e.fk_parent"; $sql = "SELECT e.rowid, e.ref as label, e.description, e.fk_parent";
if (!empty($fk_product)) if (!empty($fk_product))
{ {
if (!empty($batch)) if (!empty($batch))
@ -125,8 +125,8 @@ class FormProduct
if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')'; if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')';
if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.label, e.description, e.fk_parent"; if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.ref, e.description, e.fk_parent";
$sql.= " ORDER BY e.label"; $sql.= " ORDER BY e.ref";
dol_syslog(get_class($this).'::loadWarehouses', LOG_DEBUG); dol_syslog(get_class($this).'::loadWarehouses', LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -447,7 +447,7 @@ class FormProduct
// clear cache // clear cache
$this->cache_lot = array(); $this->cache_lot = array();
$productIdList = implode(',', $productIdArray); $productIdList = implode(',', $productIdArray);
$sql = "SELECT pb.batch, pb.rowid, ps.fk_entrepot, pb.qty, e.label, ps.fk_product"; $sql = "SELECT pb.batch, pb.rowid, ps.fk_entrepot, pb.qty, e.ref as label, ps.fk_product";
$sql.= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; $sql.= " FROM ".MAIN_DB_PREFIX."product_batch as pb";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.rowid = pb.fk_product_stock"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.rowid = pb.fk_product_stock";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (".getEntity('stock').")"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (".getEntity('stock').")";
@ -455,7 +455,7 @@ class FormProduct
{ {
$sql.= " WHERE ps.fk_product IN (".$productIdList.")"; $sql.= " WHERE ps.fk_product IN (".$productIdList.")";
} }
$sql.= " ORDER BY e.label, pb.batch"; $sql.= " ORDER BY e.ref, pb.batch";
dol_syslog(get_class($this).'::loadLotStock', LOG_DEBUG); dol_syslog(get_class($this).'::loadLotStock', LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -30,6 +30,7 @@ $langs->loadLangs(array("inventory","other"));
// Get parameters // Get parameters
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
@ -53,12 +54,10 @@ foreach($object->fields as $key => $val)
if (empty($action) && empty($id) && empty($ref)) $action='view'; if (empty($action) && empty($id) && empty($ref)) $action='view';
// Protection if external user // Security check - Protection if external user
if ($user->societe_id > 0) //if ($user->societe_id > 0) access_forbidden();
{ //if ($user->societe_id > 0) $socid = $user->societe_id;
//accessforbidden(); //$result = restrictedArea($user, 'mymodule', $id);
}
//$result = restrictedArea($user, 'inventory', $id);
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
@ -69,7 +68,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu
/* /*
* ACTIONS * Actions
*/ */
$parameters=array(); $parameters=array();
@ -86,13 +85,22 @@ if (empty($reshook))
// Actions cancel, add, update or delete // Actions cancel, add, update or delete
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
// Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails
/*$trigger_name='MYOBJECT_SENTBYMAIL';
$autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
$trackid='myobject'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';*/
} }
/* /*
* VIEW * View
*/ */
$form=new Form($db); $form=new Form($db);
@ -128,38 +136,9 @@ if ($action == 'create')
dol_fiche_head(array(), ''); dol_fiche_head(array(), '');
print '<table class="border centpercent">'."\n"; print '<table class="border centpercent">'."\n";
foreach($object->fields as $key => $val)
{ // Common attributes
if (in_array($key, array('rowid', 'entity', 'date_creation', 'date_validation', 'tms', 'fk_user_creat', 'fk_user_modif', 'fk_user_valid', 'import_key'))) continue; include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';
print '<tr id="field_'.$key.'">';
print '<td';
print ' class="titlefieldcreate';
if ($val['notnull'] > 0) print ' fieldrequired';
if ($val['type'] == 'text') print ' tdtop';
print '"';
print '>';
print $langs->trans($val['label']);
print '</td>';
print '<td>';
$defaultcss='minwidth100';
if ($val['type'] == 'text')
{
print '<textarea class="flat quatrevingtpercent" rows="'.ROWS_4.'" name="'.$key.'">';
print GETPOST($key,'none');
print '</textarea>';
}
elseif (is_array($val['arrayofkeyval']))
{
print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int'));
}
else
{
$cssforinput = empty($val['css'])?$defaultcss:$val['css'];
print '<input class="flat'.($cssforinput?' '.$cssforinput:'').'" class="'.$cssforinput.'" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'">';
}
print '</td>';
print '</tr>';
}
// Other attributes // Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';
@ -171,20 +150,19 @@ if ($action == 'create')
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">'; print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
print '&nbsp; '; print '&nbsp; ';
print '<input type="button" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" onclick="javascript:history.go(-1)">'; // Cancel for create doe not post form print '<input type="'.($backtopage?"submit":"button").'" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage?'':' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage
print '</div>'; print '</div>';
print '</form>'; print '</form>';
} }
// Part to edit record // Part to edit record
if (($id || $ref) && $action == 'edit') if (($id || $ref) && $action == 'edit')
{ {
print load_fiche_titre($langs->trans("Inventory")); print load_fiche_titre($langs->trans("Inventory"));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
@ -192,36 +170,9 @@ if (($id || $ref) && $action == 'edit')
dol_fiche_head(); dol_fiche_head();
print '<table class="border centpercent">'."\n"; print '<table class="border centpercent">'."\n";
foreach($object->fields as $key => $val)
{
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
print '<tr><td'; // Common attributes
print ' class="titlefieldcreate'; include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';
if ($val['notnull'] > 0) print ' fieldrequired';
if ($val['type'] == 'text') print ' tdtop';
print '"';
print '>'.$langs->trans($val['label']).'</td>';
print '<td>';
$defaultcss='minwidth100';
if ($val['type'] == 'text')
{
print '<textarea class="flat quatrevingtpercent" rows="'.ROWS_4.'" name="'.$key.'">';
print GETPOST($key,'none')?GETPOST($key,'none'):$object->$key;
print '</textarea>';
}
elseif (is_array($val['arrayofkeyval']))
{
print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')!=''?GETPOST($key, 'int'):$object->$key);
}
else
{
$cssforinput = empty($val['css'])?$defaultcss:$val['css'];
print '<input class="flat'.($cssforinput?' '.$cssforinput:'').'" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):$object->$key).'">';
}
print '</td>';
print '</tr>';
}
// Other attributes // Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
@ -237,22 +188,19 @@ if (($id || $ref) && $action == 'edit')
print '</form>'; print '</form>';
} }
// Part to show record // Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
{ {
$res = $object->fetch_optionals($object->id, $extralabels); $res = $object->fetch_optionals($object->id, $extralabels);
$head = inventory_prepare_head($object); $head = inventory_prepare_head($object);
dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), -1, 'order'); dol_fiche_head($head, 'inventory', $langs->trans("Inventory"), -1, 'inventory');
$formconfirm = ''; $formconfirm = '';
// Confirmation to delete // Confirmation to delete
if ($action == 'delete') { if ($action == 'delete') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1);
} }
// Confirmation of action xxxx // Confirmation of action xxxx
@ -280,13 +228,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print $formconfirm; print $formconfirm;
// Object card // Object card
// ------------------------------------------------------------ // ------------------------------------------------------------
$linkback = '<a href="' . DOL_URL_ROOT . '/inventory/inventory_list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/inventory/inventory_list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
/* /*
// Ref bis // Ref bis
@ -339,24 +285,25 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'."\n"; print '<table class="border centpercent">'."\n";
// print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
// LIST_OF_TD_LABEL_FIELDS_VIEW
// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
// Other attributes // Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
/* Second column
print '<div class="fichehalfright">'; print '<div class="fichehalfright">';
print '<div class="ficheaddleft">'; print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
print '</table>'; print '</table>';
print '</div>'; print '</div>';*/
print '</div>'; print '</div>';
print '</div>'; print '</div>';
@ -375,16 +322,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (empty($reshook)) if (empty($reshook))
{ {
// Send // Send
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendByMail') . '</a></div>'."\n"; print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n";
if ($user->rights->inventory->write) if ($user->rights->inventory->write)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n";
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
} }
if ($user->rights->inventory->delete) if ($user->rights->inventory->delete)
{ {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a></div>'."\n"; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
} }
} }
print '</div>'."\n"; print '</div>'."\n";
@ -400,27 +355,34 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
{ {
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
// Documents
$comref = dol_sanitizeFileName($object->ref);
$relativepath = $comref . '/' . $comref . '.pdf';
$filedir = $conf->product->dir_output . '/inventory/' . $comref;
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
$genallowed = $user->rights->inventory->read;
$delallowed = $user->rights->inventory->create;
print $formfile->showdocuments('inventory', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
// Documents
/*$objref = dol_sanitizeFileName($object->ref);
$relativepath = $comref . '/' . $comref . '.pdf';
$filedir = $conf->mymodule->dir_output . '/' . $objref;
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
$genallowed = $user->rights->mymodule->read; // If you can read, you can build the PDF to read content
$delallowed = $user->rights->mymodule->create; // If you can create/edit, you can remove a file on card
print $formfile->showdocuments('mymodule', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
*/
// Show links to link elements // Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); $linktoelem = $form->showLinkToObjectBlock($object, null, array('inventory'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
$MAXEVENT = 10;
$morehtmlright = '<a href="'.dol_buildpath('/mymodule/myobject_info.php', 1).'?id='.$object->id.'">';
$morehtmlright.= $langs->trans("SeeAll");
$morehtmlright.= '</a>';
// List of actions on element // List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db); $formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'order', $socid, 1); $somethingshown = $formactions->showactions($object, 'inventory', $socid, 1, '', $MAXEVENT, '', $morehtmlright);
print '</div></div></div>'; print '</div></div></div>';
} }

View File

@ -74,7 +74,7 @@ class Inventory extends CommonObject
'ref' => array('type'=>'varchar(64)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Reference of object',), 'ref' => array('type'=>'varchar(64)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Reference of object',),
'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,),
'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300'), 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300'),
'fk_warehouse' => array('type'=>'integer', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'index'=>1,), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'index'=>1, 'help'=>'LinkToThirparty'),
'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>1,), 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>1,),
'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'index'=>1,), 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'index'=>1,),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500,),

View File

@ -114,7 +114,7 @@ $sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price
$sql.= ' p.fk_product_type, p.tms as datem,'; $sql.= ' p.fk_product_type, p.tms as datem,';
$sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tobatch,'; $sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tobatch,';
$sql.= ' ps.fk_entrepot,'; $sql.= ' ps.fk_entrepot,';
$sql.= ' e.label as warehouse_ref, e.lieu as warehouse_lieu, e.fk_parent as warehouse_parent,'; $sql.= ' e.ref as warehouse_ref, e.lieu as warehouse_lieu, e.fk_parent as warehouse_parent,';
$sql.= ' pb.batch, pb.eatby as oldeatby, pb.sellby as oldsellby,'; $sql.= ' pb.batch, pb.eatby as oldeatby, pb.sellby as oldsellby,';
$sql.= ' pl.rowid as lotid, pl.eatby, pl.sellby,'; $sql.= ' pl.rowid as lotid, pl.eatby, pl.sellby,';
$sql.= ' SUM(pb.qty) as stock_physique, COUNT(pb.rowid) as nbinbatchtable'; $sql.= ' SUM(pb.qty) as stock_physique, COUNT(pb.rowid) as nbinbatchtable';
@ -150,13 +150,13 @@ if($catid) $sql.= " AND cp.fk_categorie = ".$catid;
if ($fourn_id > 0) $sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; if ($fourn_id > 0) $sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
// Insert categ filter // Insert categ filter
if ($search_categ) $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ); if ($search_categ) $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ);
if ($search_warehouse) $sql .= natural_search("e.label", $search_warehouse); if ($search_warehouse) $sql .= natural_search("e.ref", $search_warehouse);
if ($search_batch) $sql .= natural_search("pb.batch", $search_batch); if ($search_batch) $sql .= natural_search("pb.batch", $search_batch);
$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,"; $sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,";
$sql.= " p.fk_product_type, p.tms,"; $sql.= " p.fk_product_type, p.tms,";
$sql.= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tobatch,"; $sql.= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tobatch,";
$sql.= " ps.fk_entrepot,"; $sql.= " ps.fk_entrepot,";
$sql.= " e.label, e.lieu, e.fk_parent,"; $sql.= " e.ref, e.lieu, e.fk_parent,";
$sql.= " pb.batch, pb.eatby, pb.sellby,"; $sql.= " pb.batch, pb.eatby, pb.sellby,";
$sql.= " pl.rowid, pl.eatby, pl.sellby"; $sql.= " pl.rowid, pl.eatby, pl.sellby";
if ($toolowstock) $sql.= " HAVING SUM(".$db->ifsql('ps.reel IS NULL', '0', 'ps.reel').") < p.seuil_stock_alerte"; // Not used yet if ($toolowstock) $sql.= " HAVING SUM(".$db->ifsql('ps.reel IS NULL', '0', 'ps.reel').") < p.seuil_stock_alerte"; // Not used yet
@ -292,7 +292,7 @@ if ($resql)
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder); print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder);
if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder); if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.label",$param,"",'',$sortfield,$sortorder); print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.ref",$param,"",'',$sortfield,$sortorder);
//print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder); //print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder);
print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pb.eatby",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pb.eatby",$param,"",'align="center"',$sortfield,$sortorder);

View File

@ -275,7 +275,7 @@ else
{ {
$head = stock_prepare_head($object); $head = stock_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("Warehouse"), 0, 'stock'); dol_fiche_head($head, 'card', $langs->trans("Warehouse"), -1, 'stock');
$formconfirm = ''; $formconfirm = '';

View File

@ -98,6 +98,8 @@ class Entrepot extends CommonObject
{ {
global $conf; global $conf;
$error = 0;
$this->libelle = trim($this->libelle); $this->libelle = trim($this->libelle);
// Si libelle non defini, erreur // Si libelle non defini, erreur
@ -111,8 +113,8 @@ class Entrepot extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (entity, datec, fk_user_author, label, fk_parent)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (ref, entity, datec, fk_user_author, fk_parent)";
$sql .= " VALUES (".$conf->entity.",'".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->libelle)."', ".($this->fk_parent > 0 ? $this->fk_parent : "NULL").")"; $sql .= " VALUES ('".$this->db->escape($this->libelle)."', ".$conf->entity.", '".$this->db->idate($now)."', ".$user->id.", ".($this->fk_parent > 0 ? $this->fk_parent : "NULL").")";
dol_syslog(get_class($this)."::create", LOG_DEBUG); dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result=$this->db->query($sql); $result=$this->db->query($sql);
@ -123,7 +125,16 @@ class Entrepot extends CommonObject
{ {
$this->id = $id; $this->id = $id;
if ($this->update($id, $user) > 0) if (! $error)
{
$result = $this->update($id, $user);
if ($result <= 0)
{
$error++;
}
}
if (! $error)
{ {
$this->db->commit(); $this->db->commit();
return $id; return $id;
@ -185,7 +196,7 @@ class Entrepot extends CommonObject
$this->country_id=($this->country_id > 0 ? $this->country_id : 0); $this->country_id=($this->country_id > 0 ? $this->country_id : 0);
$sql = "UPDATE ".MAIN_DB_PREFIX."entrepot "; $sql = "UPDATE ".MAIN_DB_PREFIX."entrepot ";
$sql .= " SET label = '" . $this->db->escape($this->libelle) ."'"; $sql .= " SET ref = '" . $this->db->escape($this->libelle) ."'";
$sql .= ", fk_parent = " . (($this->fk_parent > 0) ? $this->fk_parent : "NULL"); $sql .= ", fk_parent = " . (($this->fk_parent > 0) ? $this->fk_parent : "NULL");
$sql .= ", description = '" . $this->db->escape($this->description) ."'"; $sql .= ", description = '" . $this->db->escape($this->description) ."'";
$sql .= ", statut = " . $this->statut; $sql .= ", statut = " . $this->statut;
@ -297,7 +308,7 @@ class Entrepot extends CommonObject
{ {
global $conf; global $conf;
$sql = "SELECT rowid, fk_parent, label, description, statut, lieu, address, zip, town, fk_pays as country_id"; $sql = "SELECT rowid, fk_parent, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
if ($id) if ($id)
{ {
@ -306,7 +317,7 @@ class Entrepot extends CommonObject
else else
{ {
$sql.= " WHERE entity = " .$conf->entity; $sql.= " WHERE entity = " .$conf->entity;
if ($ref) $sql.= " AND label = '".$this->db->escape($ref)."'"; if ($ref) $sql.= " AND ref = '".$this->db->escape($ref)."'";
} }
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
@ -319,8 +330,8 @@ class Entrepot extends CommonObject
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->fk_parent = $obj->fk_parent; $this->fk_parent = $obj->fk_parent;
$this->ref = $obj->rowid; $this->ref = $obj->label;
$this->label = $obj->label; $this->label = $obj->label; // deprecated
$this->libelle = $obj->label; // deprecated $this->libelle = $obj->label; // deprecated
$this->description = $obj->description; $this->description = $obj->description;
$this->statut = $obj->statut; $this->statut = $obj->statut;
@ -409,7 +420,7 @@ class Entrepot extends CommonObject
{ {
$liste = array(); $liste = array();
$sql = "SELECT rowid, label"; $sql = "SELECT rowid, ref as label";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot";
$sql.= " WHERE entity IN (".getEntity('stock').")"; $sql.= " WHERE entity IN (".getEntity('stock').")";
$sql.= " AND statut = ".$status; $sql.= " AND statut = ".$status;
@ -574,7 +585,7 @@ class Entrepot extends CommonObject
$label = ''; $label = '';
$label = '<u>' . $langs->trans("ShowWarehouse").'</u>'; $label = '<u>' . $langs->trans("ShowWarehouse").'</u>';
$label.= '<br><b>' . $langs->trans('Ref') . ':</b> ' . (empty($this->label)?$this->libelle:$this->label); $label.= '<br><b>' . $langs->trans('Ref') . ':</b> ' . (empty($this->ref)?(empty($this->label)?$this->libelle:$this->label):$this->ref);
if (! empty($this->lieu)) if (! empty($this->lieu))
$label.= '<br><b>' . $langs->trans('LocationSummary').':</b> '.$this->lieu; $label.= '<br><b>' . $langs->trans('LocationSummary').':</b> '.$this->lieu;

View File

@ -25,6 +25,7 @@
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$langs->load("stocks"); $langs->load("stocks");
$langs->load("productbatch"); $langs->load("productbatch");
@ -37,6 +38,8 @@ $result=restrictedArea($user,'stock');
* View * View
*/ */
$producttmp=new Product($db);
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks'; $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
llxHeader("",$langs->trans("Stocks"),$help_url); llxHeader("",$langs->trans("Stocks"),$help_url);
@ -61,7 +64,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
} }
$sql = "SELECT e.label, e.rowid, e.statut"; $sql = "SELECT e.ref as label, e.rowid, e.statut";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql.= " WHERE e.statut in (0,1)"; $sql.= " WHERE e.statut in (0,1)";
$sql.= " AND e.entity IN (".getEntity('stock').")"; $sql.= " AND e.entity IN (".getEntity('stock').")";
@ -111,8 +114,8 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Last movements // Last movements
$max=10; $max=10;
$sql = "SELECT p.rowid, p.label as produit,"; $sql = "SELECT p.rowid, p.label as produit, p.tobatch, p.tosell, p.tobuy,";
$sql.= " e.label as stock, e.rowid as entrepot_id,"; $sql.= " e.ref as stock, e.rowid as entrepot_id,";
$sql.= " m.value as qty, m.datem, m.batch, m.eatby, m.sellby"; $sql.= " m.value as qty, m.datem, m.batch, m.eatby, m.sellby";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql.= ", ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql.= ", ".MAIN_DB_PREFIX."stock_mouvement as m";
@ -144,7 +147,6 @@ if ($resql)
print '<th align="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/product/stock/mouvement.php">'.$langs->trans("FullList").'</a></th>'; print '<th align="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/product/stock/mouvement.php">'.$langs->trans("FullList").'</a></th>';
print "</tr>\n"; print "</tr>\n";
$var=True;
$i=0; $i=0;
while ($i < min($num,$max)) while ($i < min($num,$max))
{ {
@ -152,9 +154,14 @@ if ($resql)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($objp->datem),'dayhour').'</td>'; print '<td>'.dol_print_date($db->jdate($objp->datem),'dayhour').'</td>';
print "<td><a href=\"../card.php?id=$objp->rowid\">"; print "<td>";
print img_object($langs->trans("ShowProduct"),"product").' '.$objp->produit; $producttmp->id = $objp->rowid;
print "</a></td>\n"; $producttmp->ref = $objp->produit;
$producttmp->status_batch = $objp->tobatch;
$producttmp->status_sell = $objp->tosell;
$producttmp->status_buy = $objp->tobuy;
print $producttmp->getNomUrl(1);
print "</td>\n";
if (! empty($conf->productbatch->enabled)) if (! empty($conf->productbatch->enabled))
{ {
print '<td>'.$objp->batch.'</td>'; print '<td>'.$objp->batch.'</td>';

View File

@ -40,7 +40,7 @@ $search_status=GETPOST("search_status","int");
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield"); $sortfield = GETPOST("sortfield");
$sortorder = GETPOST("sortorder"); $sortorder = GETPOST("sortorder");
if (! $sortfield) $sortfield="e.label"; if (! $sortfield) $sortfield="e.ref";
if (! $sortorder) $sortorder="ASC"; if (! $sortorder) $sortorder="ASC";
$page = GETPOST("page"); $page = GETPOST("page");
if ($page < 0) $page = 0; if ($page < 0) $page = 0;
@ -50,7 +50,7 @@ $year = strftime("%Y",time());
// List of fields to search into when doing a "search in all" // List of fields to search into when doing a "search in all"
$fieldstosearchall = array( $fieldstosearchall = array(
'e.label'=>"Ref", 'e.ref'=>"Ref",
'e.lieu'=>"LocationSummary", 'e.lieu'=>"LocationSummary",
'e.description'=>"Description", 'e.description'=>"Description",
'e.address'=>"Address", 'e.address'=>"Address",
@ -82,17 +82,17 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
$form=new Form($db); $form=new Form($db);
$warehouse=new Entrepot($db); $warehouse=new Entrepot($db);
$sql = "SELECT e.rowid, e.label as ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent,"; $sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent,";
$sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; $sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $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_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.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";
$sql.= " WHERE e.entity IN (".getEntity('stock').")"; $sql.= " WHERE e.entity IN (".getEntity('stock').")";
if ($search_ref) $sql.= natural_search("e.label", $search_ref); // ref if ($search_ref) $sql.= natural_search("e.ref", $search_ref); // ref
if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label
if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status; if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status;
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $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, e.fk_parent"; $sql.= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent";
$totalnboflines=0; $totalnboflines=0;
$result=$db->query($sql); $result=$db->query($sql);
if ($result) if ($result)
@ -125,10 +125,10 @@ if ($result)
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_ref) $param.="&search_ref=".$search_ref; if ($search_ref) $param.="&search_ref=".urlencode($search_ref);
if ($search_label) $param.="&search_label=".$search_label; if ($search_label) $param.="&search_label=".urlencode($search_label);
if ($search_status) $param.="&search_status=".$search_status; if ($search_status) $param.="&search_status=".urlencode($search_status);
if ($sall) $param.="&sall=".$sall; if ($sall) $param.="&sall=".urlencode($sall);
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -176,7 +176,7 @@ if ($result)
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Ref",$_SERVER["PHP_SELF"], "e.label","",$param,"",$sortfield,$sortorder); print_liste_field_titre("Ref",$_SERVER["PHP_SELF"], "e.ref","",$param,"",$sortfield,$sortorder);
print_liste_field_titre("LocationSummary",$_SERVER["PHP_SELF"], "e.lieu","",$param,"",$sortfield,$sortorder); print_liste_field_titre("LocationSummary",$_SERVER["PHP_SELF"], "e.lieu","",$param,"",$sortfield,$sortorder);
print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stockqty",'',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stockqty",'',$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue",'',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue",'',$param,'align="right"',$sortfield,$sortorder);
@ -194,6 +194,7 @@ if ($result)
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$warehouse->id = $objp->rowid; $warehouse->id = $objp->rowid;
$warehouse->ref = $objp->ref;
$warehouse->label = $objp->ref; $warehouse->label = $objp->ref;
$warehouse->lieu = $objp->lieu; $warehouse->lieu = $objp->lieu;
$warehouse->fk_parent = $objp->fk_parent; $warehouse->fk_parent = $objp->fk_parent;

View File

@ -95,7 +95,7 @@ $arrayfields=array(
'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(! empty($conf->productbatch->enabled))), 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(! empty($conf->productbatch->enabled))),
'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))),
'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(! empty($conf->productbatch->enabled))), 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(! empty($conf->productbatch->enabled))),
'e.label'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(! $id > 0)), // If we are on specific warehouse, we hide it 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(! $id > 0)), // If we are on specific warehouse, we hide it
'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0),
'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1),
'm.label'=>array('label'=>$langs->trans("LabelMovement"), 'checked'=>1), 'm.label'=>array('label'=>$langs->trans("LabelMovement"), 'checked'=>1),
@ -414,7 +414,7 @@ $formproduct=new FormProduct($db);
if (!empty($conf->projet->enabled)) $formproject=new FormProjets($db); if (!empty($conf->projet->enabled)) $formproject=new FormProjets($db);
$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.fk_product_type as type, p.entity,"; $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.fk_product_type as type, p.entity,";
$sql.= " e.label as stock, e.rowid as entrepot_id, e.lieu,"; $sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,";
$sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
$sql.= " m.batch,"; $sql.= " m.batch,";
$sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,";
@ -529,7 +529,7 @@ if ($resql)
{ {
$head = stock_prepare_head($object); $head = stock_prepare_head($object);
dol_fiche_head($head, 'movements', $langs->trans("Warehouse"), 0, 'stock'); dol_fiche_head($head, 'movements', $langs->trans("Warehouse"), -1, 'stock');
$linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/list.php">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/list.php">'.$langs->trans("BackToList").'</a>';
@ -783,7 +783,7 @@ if ($resql)
print '</td>'; print '</td>';
} }
// Warehouse // Warehouse
if (! empty($arrayfields['e.label']['checked'])) if (! empty($arrayfields['e.ref']['checked']))
{ {
print '<td class="liste_titre maxwidthonsmartphone" align="left">'; print '<td class="liste_titre maxwidthonsmartphone" align="left">';
//print '<input class="flat" type="text" size="8" name="search_warehouse" value="'.($search_warehouse).'">'; //print '<input class="flat" type="text" size="8" name="search_warehouse" value="'.($search_warehouse).'">';
@ -879,7 +879,7 @@ if ($resql)
if (! empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'],$_SERVER["PHP_SELF"],'m.batch','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'],$_SERVER["PHP_SELF"],'m.batch','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'],$_SERVER["PHP_SELF"],'pl.eatby','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'],$_SERVER["PHP_SELF"],'pl.eatby','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'],$_SERVER["PHP_SELF"],'pl.sellby','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'],$_SERVER["PHP_SELF"],'pl.sellby','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['e.label']['checked'])) print_liste_field_titre($arrayfields['e.label']['label'],$_SERVER["PHP_SELF"], "e.label","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'],$_SERVER["PHP_SELF"], "e.ref","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible
if (! empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'],$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'],$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'],$_SERVER["PHP_SELF"], "m.inventorycode","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'],$_SERVER["PHP_SELF"], "m.inventorycode","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'],$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'],$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder);
@ -982,7 +982,7 @@ if ($resql)
print '<td align="center">'. dol_print_date($objp->sellby,'day') .'</td>'; print '<td align="center">'. dol_print_date($objp->sellby,'day') .'</td>';
} }
// Warehouse // Warehouse
if (! empty($arrayfields['e.label']['checked'])) if (! empty($arrayfields['e.ref']['checked']))
{ {
print '<td>'; print '<td>';
print $warehousestatic->getNomUrl(1); print $warehousestatic->getNomUrl(1);

View File

@ -813,7 +813,7 @@ if ((! empty($conf->productbatch->enabled)) && $object->hasbatch())
print '</tr>'; print '</tr>';
} }
$sql = "SELECT e.rowid, e.label, e.lieu, ps.reel, ps.rowid as product_stock_id, p.pmp"; $sql = "SELECT e.rowid, e.ref as label, e.lieu, ps.reel, ps.rowid as product_stock_id, p.pmp";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
$sql.= " ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= " ".MAIN_DB_PREFIX."product_stock as ps";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product";
@ -821,7 +821,7 @@ $sql.= " WHERE ps.reel != 0";
$sql.= " AND ps.fk_entrepot = e.rowid"; $sql.= " AND ps.fk_entrepot = e.rowid";
$sql.= " AND e.entity IN (".getEntity('stock').")"; $sql.= " AND e.entity IN (".getEntity('stock').")";
$sql.= " AND ps.fk_product = ".$object->id; $sql.= " AND ps.fk_product = ".$object->id;
$sql.= " ORDER BY e.label"; $sql.= " ORDER BY e.ref";
$entrepotstatic=new Entrepot($db); $entrepotstatic=new Entrepot($db);
$product_lot_static=new Productlot($db); $product_lot_static=new Productlot($db);

View File

@ -263,7 +263,7 @@ $formproduct = new FormProduct($db);
$title = $langs->trans('Status'); $title = $langs->trans('Status');
if(!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) {
$sqldesiredtock=$db->ifsql("pse.desiredstock IS NULL", "p.desiredstock", "pse.desiredstock"); $sqldesiredtock=$db->ifsql("pse.desiredstock IS NULL", "p.desiredstock", "pse.desiredstock");
$sqlalertstock=$db->ifsql("pse.seuil_stock_alerte IS NULL", "p.seuil_stock_alerte", "pse.seuil_stock_alerte"); $sqlalertstock=$db->ifsql("pse.seuil_stock_alerte IS NULL", "p.seuil_stock_alerte", "pse.seuil_stock_alerte");
} else { } else {
@ -427,9 +427,12 @@ print '<input type="hidden" name="snom" value="'.$snom.'">';
print '<input type="hidden" name="salert" value="'.$salert.'">'; print '<input type="hidden" name="salert" value="'.$salert.'">';
print '<input type="hidden" name="draftorder" value="'.$draftorder.'">'; print '<input type="hidden" name="draftorder" value="'.$draftorder.'">';
print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">';
print '<div class="inline-block valignmiddle" style="padding-right: 20px;">'; if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE))
print $langs->trans('Warehouse').' '.$formproduct->selectWarehouses($fk_entrepot, 'fk_entrepot', '', 1); {
print '</div>'; print '<div class="inline-block valignmiddle" style="padding-right: 20px;">';
print $langs->trans('Warehouse').' '.$formproduct->selectWarehouses($fk_entrepot, 'fk_entrepot', '', 1);
print '</div>';
}
print '<div class="inline-block valignmiddle" style="padding-right: 20px;">'; print '<div class="inline-block valignmiddle" style="padding-right: 20px;">';
print $langs->trans('Supplier').' '.$form->select_company($fk_supplier, 'fk_supplier', 'fournisseur=1', 1); print $langs->trans('Supplier').' '.$form->select_company($fk_supplier, 'fk_supplier', 'fournisseur=1', 1);
print '</div>'; print '</div>';

View File

@ -37,7 +37,7 @@ $sall=GETPOST('sall', 'alphanohtml');
$sortfield = GETPOST("sortfield"); $sortfield = GETPOST("sortfield");
$sortorder = GETPOST("sortorder"); $sortorder = GETPOST("sortorder");
if (! $sortfield) $sortfield="e.label"; if (! $sortfield) $sortfield="e.ref";
if (! $sortorder) $sortorder="ASC"; if (! $sortorder) $sortorder="ASC";
$page = $_GET["page"]; $page = $_GET["page"];
if ($page < 0) $page = 0; if ($page < 0) $page = 0;
@ -51,25 +51,22 @@ $year = strftime("%Y",time());
* View * View
*/ */
$sql = "SELECT e.rowid, e.label as ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays,"; $sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays,";
$sql.= " SUM(ps.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; $sql.= " SUM(ps.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $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_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.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";
$sql.= " WHERE e.entity IN (".getEntity('stock').")"; $sql.= " WHERE e.entity IN (".getEntity('stock').")";
if ($sref) if ($sref) $sql.= natural_search("e.ref", $sref);
{
$sql.= " AND e.label LIKE '%".$db->escape($sref)."%'";
}
if ($sall) if ($sall)
{ {
$sql.= " AND (e.label LIKE '%".$db->escape($sall)."%'"; $sql.= " AND (e.ref LIKE '%".$db->escape($sall)."%'";
$sql.= " OR e.description LIKE '%".$db->escape($sall)."%'"; $sql.= " OR e.description LIKE '%".$db->escape($sall)."%'";
$sql.= " OR e.lieu LIKE '%".$db->escape($sall)."%'"; $sql.= " OR e.lieu LIKE '%".$db->escape($sall)."%'";
$sql.= " OR e.address LIKE '%".$db->escape($sall)."%'"; $sql.= " OR e.address LIKE '%".$db->escape($sall)."%'";
$sql.= " OR e.town LIKE '%".$db->escape($sall)."%')"; $sql.= " OR e.town LIKE '%".$db->escape($sall)."%')";
} }
$sql.= " GROUP BY e.rowid, e.label, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays"; $sql.= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays";
$sql.= $db->order($sortfield,$sortorder); $sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit + 1, $offset); $sql.= $db->plimit($limit + 1, $offset);
@ -87,7 +84,7 @@ if ($result)
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.label","","","",$sortfield,$sortorder); print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.ref","","","",$sortfield,$sortorder);
print_liste_field_titre("LocationSummary", $_SERVER["PHP_SELF"], "e.lieu","","","",$sortfield,$sortorder); print_liste_field_titre("LocationSummary", $_SERVER["PHP_SELF"], "e.lieu","","","",$sortfield,$sortorder);
print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "e.valo_pmp",'','','align="right"',$sortfield,$sortorder); print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "e.valo_pmp",'','','align="right"',$sortfield,$sortorder);
print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "",'','','align="right"',$sortfield,$sortorder); print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "",'','','align="right"',$sortfield,$sortorder);