Skip to content

Commit

Permalink
Standardize database: field ref of warehouse was renamed label -> ref
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 24, 2017
1 parent 3db52b5 commit 9f235e1
Show file tree
Hide file tree
Showing 17 changed files with 189 additions and 191 deletions.
2 changes: 1 addition & 1 deletion htdocs/commande/class/commande.class.php
Expand Up @@ -768,7 +768,7 @@ function create($user, $notrigger=0)
$sql.= ", multicurrency_code";
$sql.= ", multicurrency_tx";
$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->db->idate($date)."'";
$sql.= ", ".($this->source>=0 && $this->source != '' ?$this->db->escape($this->source):'null');
Expand Down
12 changes: 6 additions & 6 deletions htdocs/expedition/card.php
Expand Up @@ -750,7 +750,7 @@
}
}
}
if ($lineIdToAddLot)
if ($lineIdToAddLot)
{
// add lot to existing line
if ($line->fetch($lineIdToAddLot) > 0)
Expand Down Expand Up @@ -787,7 +787,7 @@
}
}
}
else
else
{
setEventMessages($lotStock->error, $lotStock->errors, 'errors');
$error++;
Expand Down Expand Up @@ -2477,7 +2477,7 @@
}

// 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)
{
Expand All @@ -2489,18 +2489,18 @@

// This is just to generate a delivery receipt
//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>';
}
// 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)
{
$label="Close"; $paramaction='classifyclosed'; // = Transferred/Received
// 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";
$paramaction='classifybilled';
Expand Down
2 changes: 2 additions & 0 deletions htdocs/install/mysql/migration/6.0.0-7.0.0.sql
Expand Up @@ -68,6 +68,8 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer;

-- 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 entity = 1 WHERE entity IS NULL;

Expand Down
4 changes: 2 additions & 2 deletions htdocs/install/mysql/tables/llx_entrepot.sql
@@ -1,6 +1,6 @@
-- ============================================================================
-- 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>
--
-- This program is free software; you can redistribute it and/or modify
Expand All @@ -21,9 +21,9 @@
create table llx_entrepot
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
ref varchar(255) NOT NULL,
datec datetime,
tms timestamp,
label varchar(255) NOT NULL,
entity integer DEFAULT 1 NOT NULL, -- multi company id
description text,
lieu varchar(64), -- resume lieu situation
Expand Down
37 changes: 26 additions & 11 deletions htdocs/modulebuilder/template/myobject_card.php
Expand Up @@ -329,6 +329,16 @@ function init_myfunc()

print '</table>';
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>';

Expand Down Expand Up @@ -359,7 +369,7 @@ function init_myfunc()
}

/*
if ($user->rights->sellyoursaas->create)
if ($user->rights->mymodule->create)
{
if ($object->status == 1)
{
Expand Down Expand Up @@ -396,13 +406,13 @@ function init_myfunc()
print '<a name="builddoc"></a>'; // ancre

// Documents
/*$comref = dol_sanitizeFileName($object->ref);
/*$objref = dol_sanitizeFileName($object->ref);
$relativepath = $comref . '/' . $comref . '.pdf';
$filedir = $conf->mymodule->dir_output . '/' . $comref;
$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', $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
Expand All @@ -426,13 +436,18 @@ function init_myfunc()
print '</div></div></div>';
}

// Presend form
$modelmail='myobject';
$defaulttopic='Information';
$diroutput = $conf->mymodule->dir_output;
$trackid = 'myobject'.$object->id;

include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
//Select mail models is same action as presend
/*
if (GETPOST('modelselected')) $action = 'presend';
// Presend form
$modelmail='inventory';
$defaulttopic='InformationMessage';
$diroutput = $conf->product->dir_output.'/inventory';
$trackid = 'stockinv'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
*/
}


Expand Down
24 changes: 12 additions & 12 deletions htdocs/product/class/html.formproduct.class.php
Expand Up @@ -87,7 +87,7 @@ function loadWarehouses($fk_product=0, $batch = '', $status='', $sumStock = true
$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($batch))
Expand Down Expand Up @@ -125,8 +125,8 @@ function loadWarehouses($fk_product=0, $batch = '', $status='', $sumStock = true

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";
$sql.= " ORDER BY e.label";
if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.ref, e.description, e.fk_parent";
$sql.= " ORDER BY e.ref";

dol_syslog(get_class($this).'::loadWarehouses', LOG_DEBUG);
$resql = $this->db->query($sql);
Expand Down Expand Up @@ -382,14 +382,14 @@ function selectLotStock($selected='',$htmlname='batch_id',$filterstatus='',$empt
{
$productIdArray = array($fk_product); // only show lot stock for product
}
else
else
{
foreach($this->cache_lot as $key => $value)
{
$productIdArray[] = $key;
}
}

foreach($productIdArray as $productId)
{
foreach($this->cache_lot[$productId] as $id => $arraytypes)
Expand Down Expand Up @@ -433,30 +433,30 @@ private function loadLotStock($productIdArray = array())
if (count($productIdArray) && count($this->cache_lot))
{
// check cache already loaded for product id's
foreach ($productIdArray as $productId)
foreach ($productIdArray as $productId)
{
$cacheLoaded = ! empty($this->cache_lot[$productId]) ? true : false;
}
}
if ($cacheLoaded)
if ($cacheLoaded)
{
return count($this->cache_lot);
}
else
else
{
// clear cache
$this->cache_lot = array();
$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.= " 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').")";
if (!empty($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);
$resql = $this->db->query($sql);
if ($resql)
Expand All @@ -473,7 +473,7 @@ private function loadLotStock($productIdArray = array())
$this->cache_lot[$obj->fk_product][$obj->rowid]['qty'] = $obj->qty;
$i++;
}

return $num;
}
else
Expand Down

0 comments on commit 9f235e1

Please sign in to comment.