Update function module inventory

This commit is contained in:
phf 2017-03-28 16:05:18 +02:00
parent 70743e1f68
commit df170769c9
4 changed files with 68 additions and 99 deletions

View File

@ -37,6 +37,8 @@ class Listview
$this->TTotalTmp=array(); $this->TTotalTmp=array();
$this->sql = ''; $this->sql = '';
$this->form = null; $this->form = null;
$this->totalRowToShow=0;
$this->totalRow=0;
} }
/** /**
@ -70,13 +72,12 @@ class Listview
,'view_type'=>'' ,'view_type'=>''
),$TParam['list']); ),$TParam['list']);
$POSTList = GETPOST('Listview');
if (empty($TParam['limit'])) $TParam['limit'] = array(); if (empty($TParam['limit'])) $TParam['limit'] = array();
if (!empty($POSTList[$this->id]['page'])) $TParam['limit']['page'] = $POSTList[$this->id]['page'];
$nbLine = !empty($user->conf->MAIN_SIZE_LISTE_LIMIT) ? $user->conf->MAIN_SIZE_LISTE_LIMIT : $conf->global->MAIN_SIZE_LISTE_LIMIT; $page = GETPOST('page');
$TParam['limit'] = array_merge(array('page'=>1, 'nbLine' => $nbLine, 'global'=>0), $TParam['limit']); if (!empty($page)) $TParam['limit']['page'] = $page+1; // TODO dolibarr start page at 0 instead 1
$TParam['limit'] = array_merge(array('page'=>1, 'nbLine' => $conf->liste_limit, 'global'=>0), $TParam['limit']);
if (GETPOST('sortfield')) if (GETPOST('sortfield'))
{ {
@ -236,11 +237,13 @@ class Listview
if(strpos($sql,'WHERE ')===false) $sql.=' WHERE 1 '; if(strpos($sql,'WHERE ')===false) $sql.=' WHERE 1 ';
if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter.x") && !GETPOST("button_removefilter"))
{
// TODO input date are not supported yet
foreach($ListPOST[$this->id]['search'] as $key => $value) foreach($ListPOST[$this->id]['search'] as $key => $value)
{ {
$TsKey = $this->getSearchKey($key, $TParam); $TsKey = $this->getSearchKey($key, $TParam);
$TSQLMore = array(); $TSQLMore = array();
$allow_is_null = $this->getSearchNull($key,$TParam); $allow_is_null = $this->getSearchNull($key,$TParam);
foreach ($TsKey as $i => &$sKey) foreach ($TsKey as $i => &$sKey)
@ -269,7 +272,7 @@ class Listview
{ {
$sql.=' AND ( '.implode(' OR ',$TSQLMore).' ) '; $sql.=' AND ( '.implode(' OR ',$TSQLMore).' ) ';
} }
}
} }
if ($sqlGROUPBY!='') $sql.=' GROUP BY '.$sqlGROUPBY; if ($sqlGROUPBY!='') $sql.=' GROUP BY '.$sqlGROUPBY;
@ -326,6 +329,7 @@ class Listview
foreach($TParam['search'] as $key => $param_search) foreach($TParam['search'] as $key => $param_search)
{ {
$value = isset($ListPOST[$this->id]['search'][$key]) ? $ListPOST[$this->id]['search'][$key] : ''; $value = isset($ListPOST[$this->id]['search'][$key]) ? $ListPOST[$this->id]['search'][$key] : '';
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) $value = '';
$typeRecherche = (is_array($param_search) && isset($param_search['recherche'])) ? $param_search['recherche'] : $param_search; $typeRecherche = (is_array($param_search) && isset($param_search['recherche'])) ? $param_search['recherche'] : $param_search;
@ -581,7 +585,13 @@ class Listview
$TField = $this->addTotalGroup($TField,$TTotalGroup); $TField = $this->addTotalGroup($TField,$TTotalGroup);
$out = $this->getJS(); $out = $this->getJS();
$out.= load_fiche_titre($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $TParam['limit']['page'], count($TField), 'title_products.png', 0, '', '', $limit);
$dolibarr_decalage = $this->totalRow > $this->totalRowToShow ? 1 : 0;
ob_start();
print_barre_liste($TParam['list']['title'], $TParam['limit']['page']-1, $_SERVER["PHP_SELF"], '&param', $TParam['sortfield'], $TParam['sortorder'], '', $this->totalRowToShow+$dolibarr_decalage, $this->totalRow, $TParam['list']['image'], 0, '', '', $TParam['limit']['nbLine']);
$out .= ob_get_clean();
$out.= '<table id="'.$this->id.'" class="liste" width="100%"><thead>'; $out.= '<table id="'.$this->id.'" class="liste" width="100%"><thead>';
$out.= '<tr class="liste_titre">'; $out.= '<tr class="liste_titre">';
@ -617,7 +627,7 @@ class Listview
if(count($TSearch)>0) if(count($TSearch)>0)
{ {
$out.='<tr class="liste_titre barre-recherche">'; $out.='<tr class="liste_titre barre-recherche">';
// foreach($TSearch as $field => $search)
foreach ($THeader as $field => $head) foreach ($THeader as $field => $head)
{ {
if ($field === 'selectedfields') if ($field === 'selectedfields')
@ -643,7 +653,10 @@ class Listview
else else
{ {
$var=true; $var=true;
$line_number = 0;
foreach($TField as $fields) foreach($TField as $fields)
{
if($this->in_view($TParam, $line_number))
{ {
$var=!$var; $var=!$var;
$out.='<tr '.$bc[$var].'> <!-- '.$field.' -->'; $out.='<tr '.$bc[$var].'> <!-- '.$field.' -->';
@ -657,6 +670,9 @@ class Listview
$out.='</tr>'; $out.='</tr>';
} }
$line_number++;
}
$out.='</tbody>'; $out.='</tbody>';
if (!empty($TParam['list']['haveTotal'])) if (!empty($TParam['list']['haveTotal']))
@ -731,6 +747,8 @@ class Listview
*/ */
private function parse_array(&$THeader, &$TField, &$TParam) private function parse_array(&$THeader, &$TField, &$TParam)
{ {
$this->totalRow = count($TField);
$this->THideFlip = array_flip($TParam['hide']); $this->THideFlip = array_flip($TParam['hide']);
$this->TTotalTmp=array(); $this->TTotalTmp=array();
@ -864,6 +882,7 @@ class Listview
if($this->in_view($TParam,$line_number)) if($this->in_view($TParam,$line_number))
{ {
$this->totalRowToShow++;
$row=array(); $trans = array(); $row=array(); $trans = array();
foreach($currentLine as $field=>$value) foreach($currentLine as $field=>$value)
{ {
@ -993,6 +1012,7 @@ class Listview
$res = $this->db->query($this->sql); $res = $this->db->query($this->sql);
if($res!==false) if($res!==false)
{ {
$this->totalRow = $this->db->num_rows($res);
dol_syslog(get_class($this)."::parse_sql id=".$this->id." sql=".$this->sql, LOG_DEBUG); dol_syslog(get_class($this)."::parse_sql id=".$this->id." sql=".$this->sql, LOG_DEBUG);
while($currentLine = $this->db->fetch_object($res)) while($currentLine = $this->db->fetch_object($res))

View File

@ -61,7 +61,8 @@ echo $list->render(Inventory::getSQL('All'), array(
), ),
'list'=>array( 'list'=>array(
'title'=>$langs->trans('inventoryListTitle'), 'title'=>$langs->trans('inventoryListTitle'),
'messageNothing'=>$langs->trans('inventoryListEmpty') 'messageNothing'=>$langs->trans('inventoryListEmpty'),
'image' => 'inventory.png@inventory'
), ),
'title'=>array( 'title'=>array(
'rowid'=>$langs->trans('Title'), 'rowid'=>$langs->trans('Title'),
@ -81,7 +82,7 @@ echo $list->render(Inventory::getSQL('All'), array(
), ),
'search'=>array( 'search'=>array(
'rowid' => array('recherche' => true, 'table' => array('i'), 'field' => array('title')), 'rowid' => array('recherche' => true, 'table' => array('i'), 'field' => array('title')),
'date_inventory'=>array('recherche' => 'calendars'), 'date_inventory'=>array('recherche' => 'calendars', 'table' => array('i'), 'field' => array('date_inventory')),
'status'=>array(1=>$langs->trans("inventoryValidate"), 0=>$langs->trans("inventoryDraft")) 'status'=>array(1=>$langs->trans("inventoryValidate"), 0=>$langs->trans("inventoryDraft"))
) )
)); ));

View File

@ -11,7 +11,7 @@ inventoryWritePermission=Update inventories
inventoryValidatePermission=Validate inventory inventoryValidatePermission=Validate inventory
inventoryTitle=Inventory inventoryTitle=Inventory
inventoryListTitle=List inventoryListTitle=Inventories
inventoryListEmpty=No inventory in progress inventoryListEmpty=No inventory in progress
inventoryCreateDelete=Create/Delete inventory inventoryCreateDelete=Create/Delete inventory
@ -50,5 +50,5 @@ InventoryFlushed=Inventory flushed
ExitEditMode=Exit edition ExitEditMode=Exit edition
inventoryDeleteLine=Delete line inventoryDeleteLine=Delete line
RegulateStock=Regulate Stock RegulateStock=Regulate Stock
ListInventory=Inventories list ListInventory=List
NewInventory=New inventory NewInventory=New inventory

View File

@ -1,52 +0,0 @@
Module104420Name = Inventory
Module104420Desc = Create and manage your inventory
inventorySetup = Inventory Setup
inventoryCreatePermission=Create new inventory
inventoryReadPermission=View inventories
inventoryWritePermission=Update inventories
inventoryValidatePermission=Validate inventory
inventoryTitle=Inventory
inventoryListTitle=List
inventoryListEmpty=No inventory in progress
inventoryCreateDelete=Create/Delete inventory
inventoryCreate=Create new
inventoryEdit=Edit
inventoryValidate=Validated
inventoryDraft=Running
inventorySelectWarehouse=Warehouse choice
inventoryConfirmCreate=Create
inventoryOfWarehouse=Inventory for warehouse : %s
inventoryErrorQtyAdd=Error : one quantity is leaser than zero
inventoryMvtStock=By inventory
inventoryWarningProductAlreadyExists=This product is already into list
SelectCategory=Category filter
SelectFournisseur=Supplier filter
inventoryOnDate=Inventory
INVENTORY_DISABLE_VIRTUAL=Allow to not destock child product from a kit on inventory
INVENTORY_USE_MIN_PA_IF_NO_LAST_PA=Use the buy price if no last buy price can be found
INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT=Stock mouvment have date of inventory
inventoryChangePMPPermission=Allow to change PMP value for a product
ColumnNewPMP=New unit PMP
OnlyProdsInStock=Do not add product without stock
TheoricalQty=Theorique qty
TheoricalValue=Theorique qty
LastPA=Last BP
CurrentPA=Curent BP
RealQty=Real Qty
RealValue=Real Value
RegulatedQty=Regulated Qty
AddInventoryProduct=Add product to inventory
AddProduct=Add
ApplyPMP=Apply PMP
FlushInventory=Flush inventory
ConfirmFlushInventory=Do you confirm this action ?
InventoryFlushed=Inventory flushed
ExitEditMode=Exit edition
inventoryDeleteLine=Delete line
RegulateStock=Regulate Stock
InventoryDate=Inventory date
DateUpdate=Last update