From df170769c93d6132a79c1796c8832167a00ac3ed Mon Sep 17 00:00:00 2001 From: phf Date: Tue, 28 Mar 2017 16:05:18 +0200 Subject: [PATCH] Update function module inventory --- htdocs/core/class/listview.class.php | 106 ++++++++++++++++----------- htdocs/inventory/list.php | 5 +- htdocs/langs/en_US/inventory.lang | 4 +- htdocs/langs/fr_FR/inventory.lang | 52 ------------- 4 files changed, 68 insertions(+), 99 deletions(-) delete mode 100644 htdocs/langs/fr_FR/inventory.lang diff --git a/htdocs/core/class/listview.class.php b/htdocs/core/class/listview.class.php index 312ef749671..cb41ffd32d6 100644 --- a/htdocs/core/class/listview.class.php +++ b/htdocs/core/class/listview.class.php @@ -37,6 +37,8 @@ class Listview $this->TTotalTmp=array(); $this->sql = ''; $this->form = null; + $this->totalRowToShow=0; + $this->totalRow=0; } /** @@ -70,13 +72,12 @@ class Listview ,'view_type'=>'' ),$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']; + $page = GETPOST('page'); + if (!empty($page)) $TParam['limit']['page'] = $page+1; // TODO dolibarr start page at 0 instead 1 - $nbLine = !empty($user->conf->MAIN_SIZE_LISTE_LIMIT) ? $user->conf->MAIN_SIZE_LISTE_LIMIT : $conf->global->MAIN_SIZE_LISTE_LIMIT; - $TParam['limit'] = array_merge(array('page'=>1, 'nbLine' => $nbLine, 'global'=>0), $TParam['limit']); + $TParam['limit'] = array_merge(array('page'=>1, 'nbLine' => $conf->liste_limit, 'global'=>0), $TParam['limit']); if (GETPOST('sortfield')) { @@ -226,7 +227,7 @@ class Listview { $ListPOST = GETPOST('Listview'); - if(!empty($ListPOST[$this->id]['search'])) + if (!empty($ListPOST[$this->id]['search'])) { $sqlGROUPBY=''; if(strpos($sql,'GROUP BY')!==false) @@ -236,43 +237,45 @@ class Listview if(strpos($sql,'WHERE ')===false) $sql.=' WHERE 1 '; - foreach($ListPOST[$this->id]['search'] as $key => $value) + if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter.x") && !GETPOST("button_removefilter")) { - $TsKey = $this->getSearchKey($key, $TParam); - $TSQLMore = array(); - - $allow_is_null = $this->getSearchNull($key,$TParam); - - foreach ($TsKey as $i => &$sKey) + // TODO input date are not supported yet + foreach($ListPOST[$this->id]['search'] as $key => $value) { - if($allow_is_null && !empty($ListPOST[$this->id]['search_on_null'][$key])) - { - $TSQLMore[] = $sKey.' IS NULL '; - $value = ''; - } + $TsKey = $this->getSearchKey($key, $TParam); + $TSQLMore = array(); + $allow_is_null = $this->getSearchNull($key,$TParam); - // Do not use empty() function, statut 0 exist - if($value != '') + foreach ($TsKey as $i => &$sKey) { - if(isset($TParam['type'][$key]) && ($TParam['type'][$key]==='date' || $TParam['type'][$key]==='datetime')) + if($allow_is_null && !empty($ListPOST[$this->id]['search_on_null'][$key])) { - $this->addSqlFromTypeDate($TSQLMore, $value, $sKey); + $TSQLMore[] = $sKey.' IS NULL '; + $value = ''; } - else + + // Do not use empty() function, statut 0 exist + if($value != '') { - $this->addSqlFromOther($TSQLMore, $value, $TParam, $sKey, $key); + if(isset($TParam['type'][$key]) && ($TParam['type'][$key]==='date' || $TParam['type'][$key]==='datetime')) + { + $this->addSqlFromTypeDate($TSQLMore, $value, $sKey); + } + else + { + $this->addSqlFromOther($TSQLMore, $value, $TParam, $sKey, $key); + } } } - } - if(!empty($TSQLMore)) - { - $sql.=' AND ( '.implode(' OR ',$TSQLMore).' ) '; + if(!empty($TSQLMore)) + { + $sql.=' AND ( '.implode(' OR ',$TSQLMore).' ) '; + } } - } - if($sqlGROUPBY!='') $sql.=' GROUP BY '.$sqlGROUPBY; + if ($sqlGROUPBY!='') $sql.=' GROUP BY '.$sqlGROUPBY; } return $sql; @@ -326,6 +329,7 @@ class Listview foreach($TParam['search'] as $key => $param_search) { $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; @@ -335,14 +339,14 @@ class Listview } else if($typeRecherche==='calendar') { - $value = GETPOST('Listview_'.$this->id.'_search_'.$key) ? mktime(0,0,0, (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'month'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'day'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'year') ) : ''; + $value = GETPOST('Listview_'.$this->id.'_search_'.$key) ? mktime(0,0,0, (int) GETPOST('Listview_'.$this->id.'_search_'.$key.'month'), (int) GETPOST('Listview_'.$this->id.'_search_'.$key.'day'), (int) GETPOST('Listview_'.$this->id.'_search_'.$key.'year') ) : ''; $fsearch = $form->select_date($value, 'Listview_'.$this->id.'_search_'.$key,0, 0, 1, "", 1, 0, 1); } else if($typeRecherche==='calendars') { - $value_start = GETPOST('Listview_'.$this->id.'_search_'.$key.'_start') ? mktime(0,0,0, (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'_startmonth'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'_startday'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'_startyear') ) : ''; - $value_end = GETPOST('Listview_'.$this->id.'_search_'.$key.'_end') ? mktime(0,0,0, (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'_endmonth'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'_endday'), (int)GETPOST('Listview_'.$this->id.'_search_'.$key.'_endyear') ) : ''; + $value_start = GETPOST('Listview_'.$this->id.'_search_'.$key.'_start') ? mktime(0,0,0, (int) GETPOST('Listview_'.$this->id.'_search_'.$key.'_startmonth'), (int) GETPOST('Listview_'.$this->id.'_search_'.$key.'_startday'), (int) GETPOST('Listview_'.$this->id.'_search_'.$key.'_startyear') ) : ''; + $value_end = GETPOST('Listview_'.$this->id.'_search_'.$key.'_end') ? mktime(0,0,0, (int) GETPOST('Listview_'.$this->id.'_search_'.$key.'_endmonth'), (int) GETPOST('Listview_'.$this->id.'_search_'.$key.'_endday'), (int) GETPOST('Listview_'.$this->id.'_search_'.$key.'_endyear') ) : ''; $fsearch = $form->select_date($value_start, 'Listview_'.$this->id.'_search_'.$key.'_start',0, 0, 1, "", 1, 0, 1) . $form->select_date($value_end, 'Listview_'.$this->id.'_search_'.$key.'_end',0, 0, 1, "", 1, 0, 1); @@ -581,7 +585,13 @@ class Listview $TField = $this->addTotalGroup($TField,$TTotalGroup); $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"], '¶m', $TParam['sortfield'], $TParam['sortorder'], '', $this->totalRowToShow+$dolibarr_decalage, $this->totalRow, $TParam['list']['image'], 0, '', '', $TParam['limit']['nbLine']); + $out .= ob_get_clean(); + + $out.= ''; $out.= ''; @@ -617,7 +627,7 @@ class Listview if(count($TSearch)>0) { $out.=''; -// foreach($TSearch as $field => $search) + foreach ($THeader as $field => $head) { if ($field === 'selectedfields') @@ -643,18 +653,24 @@ class Listview else { $var=true; + $line_number = 0; foreach($TField as $fields) { - $var=!$var; - $out.=''; - - foreach ($THeader as $field => $head) + if($this->in_view($TParam, $line_number)) { - $moreattrib = 'style="width:'.$head['width'].';text-align:'.$head['text-align'].'"'; - $out.=''; + $var=!$var; + $out.=''; + + foreach ($THeader as $field => $head) + { + $moreattrib = 'style="width:'.$head['width'].';text-align:'.$head['text-align'].'"'; + $out.=''; + } + + $out.=''; } - - $out.=''; + + $line_number++; } $out.=''; @@ -731,6 +747,8 @@ class Listview */ private function parse_array(&$THeader, &$TField, &$TParam) { + $this->totalRow = count($TField); + $this->THideFlip = array_flip($TParam['hide']); $this->TTotalTmp=array(); @@ -864,6 +882,7 @@ class Listview if($this->in_view($TParam,$line_number)) { + $this->totalRowToShow++; $row=array(); $trans = array(); foreach($currentLine as $field=>$value) { @@ -993,6 +1012,7 @@ class Listview $res = $this->db->query($this->sql); 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); while($currentLine = $this->db->fetch_object($res)) diff --git a/htdocs/inventory/list.php b/htdocs/inventory/list.php index 1f1150fb158..cb5b2593c32 100644 --- a/htdocs/inventory/list.php +++ b/htdocs/inventory/list.php @@ -61,7 +61,8 @@ echo $list->render(Inventory::getSQL('All'), array( ), 'list'=>array( 'title'=>$langs->trans('inventoryListTitle'), - 'messageNothing'=>$langs->trans('inventoryListEmpty') + 'messageNothing'=>$langs->trans('inventoryListEmpty'), + 'image' => 'inventory.png@inventory' ), 'title'=>array( 'rowid'=>$langs->trans('Title'), @@ -81,7 +82,7 @@ echo $list->render(Inventory::getSQL('All'), array( ), 'search'=>array( '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")) ) )); diff --git a/htdocs/langs/en_US/inventory.lang b/htdocs/langs/en_US/inventory.lang index 152aceed862..db92cb9a14a 100644 --- a/htdocs/langs/en_US/inventory.lang +++ b/htdocs/langs/en_US/inventory.lang @@ -11,7 +11,7 @@ inventoryWritePermission=Update inventories inventoryValidatePermission=Validate inventory inventoryTitle=Inventory -inventoryListTitle=List +inventoryListTitle=Inventories inventoryListEmpty=No inventory in progress inventoryCreateDelete=Create/Delete inventory @@ -50,5 +50,5 @@ InventoryFlushed=Inventory flushed ExitEditMode=Exit edition inventoryDeleteLine=Delete line RegulateStock=Regulate Stock -ListInventory=Inventories list +ListInventory=List NewInventory=New inventory \ No newline at end of file diff --git a/htdocs/langs/fr_FR/inventory.lang b/htdocs/langs/fr_FR/inventory.lang deleted file mode 100644 index 546a5202976..00000000000 --- a/htdocs/langs/fr_FR/inventory.lang +++ /dev/null @@ -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 \ No newline at end of file
'.$fields[$field].'
'.$fields[$field].'