Move new feature inventory into module stock.
This commit is contained in:
parent
92b5f8d85e
commit
4993a43025
@ -32,7 +32,7 @@ class CoreObject extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* @var Array $_fields Fields to synchronize with Database
|
* @var Array $_fields Fields to synchronize with Database
|
||||||
*/
|
*/
|
||||||
protected $__fields=array();
|
protected $fields=array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -55,9 +55,9 @@ class CoreObject extends CommonObject
|
|||||||
$this->datec = 0;
|
$this->datec = 0;
|
||||||
$this->tms = 0;
|
$this->tms = 0;
|
||||||
|
|
||||||
if (!empty($this->__fields))
|
if (!empty($this->fields))
|
||||||
{
|
{
|
||||||
foreach ($this->__fields as $field=>$info)
|
foreach ($this->fields as $field=>$info)
|
||||||
{
|
{
|
||||||
if ($this->is_date($info)) $this->{$field} = time();
|
if ($this->is_date($info)) $this->{$field} = time();
|
||||||
elseif ($this->is_array($info)) $this->{$field} = array();
|
elseif ($this->is_array($info)) $this->{$field} = array();
|
||||||
@ -87,9 +87,9 @@ class CoreObject extends CommonObject
|
|||||||
*/
|
*/
|
||||||
private function checkFieldType($field, $type)
|
private function checkFieldType($field, $type)
|
||||||
{
|
{
|
||||||
if (isset($this->__fields[$field]) && method_exists($this, 'is_'.$type))
|
if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type))
|
||||||
{
|
{
|
||||||
return $this->{'is_'.$type}($this->__fields[$field]);
|
return $this->{'is_'.$type}($this->fields[$field]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -214,7 +214,7 @@ class CoreObject extends CommonObject
|
|||||||
private function set_save_query()
|
private function set_save_query()
|
||||||
{
|
{
|
||||||
$query=array();
|
$query=array();
|
||||||
foreach ($this->__fields as $field=>$info)
|
foreach ($this->fields as $field=>$info)
|
||||||
{
|
{
|
||||||
if($this->is_date($info))
|
if($this->is_date($info))
|
||||||
{
|
{
|
||||||
@ -260,7 +260,7 @@ class CoreObject extends CommonObject
|
|||||||
*/
|
*/
|
||||||
private function get_field_list()
|
private function get_field_list()
|
||||||
{
|
{
|
||||||
$keys = array_keys($this->__fields);
|
$keys = array_keys($this->fields);
|
||||||
return implode(',', $keys);
|
return implode(',', $keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ class CoreObject extends CommonObject
|
|||||||
*/
|
*/
|
||||||
private function set_vars_by_db(&$obj)
|
private function set_vars_by_db(&$obj)
|
||||||
{
|
{
|
||||||
foreach ($this->__fields as $field => $info)
|
foreach ($this->fields as $field => $info)
|
||||||
{
|
{
|
||||||
if($this->is_date($info))
|
if($this->is_date($info))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -294,15 +294,27 @@ class Listview
|
|||||||
*/
|
*/
|
||||||
public function render($sql, $TParam=array())
|
public function render($sql, $TParam=array())
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$TField=array();
|
$TField=array();
|
||||||
|
|
||||||
$this->init($TParam);
|
$this->init($TParam);
|
||||||
|
|
||||||
$THeader = $this->initHeader($TParam);
|
$THeader = $this->initHeader($TParam);
|
||||||
|
|
||||||
$sql = $this->search($sql,$TParam);
|
$sql = $this->search($sql,$TParam);
|
||||||
$sql = $this->order_by($sql, $TParam);
|
$sql.= $this->db->order($TParam['param']['sortfield'], $TParam['param']['sortorder']);
|
||||||
|
|
||||||
|
$nbtotalofrecords = '';
|
||||||
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||||
|
{
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
$nbtotalofrecords = $this->db->num_rows($result);
|
||||||
|
}
|
||||||
|
$sql.= $this->db->plimit($TParam['param']['limit'] + 1, $TParam['param']['offset']);
|
||||||
|
|
||||||
$this->parse_sql($THeader, $TField, $TParam, $sql);
|
$this->parse_sql($THeader, $TField, $TParam, $sql);
|
||||||
|
|
||||||
list($TTotal, $TTotalGroup)=$this->get_total($TField, $TParam);
|
list($TTotal, $TTotalGroup)=$this->get_total($TField, $TParam);
|
||||||
|
|
||||||
return $this->renderList($THeader, $TField, $TTotal, $TTotalGroup, $TParam);
|
return $this->renderList($THeader, $TField, $TTotal, $TTotalGroup, $TParam);
|
||||||
@ -468,6 +480,7 @@ class Listview
|
|||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
private function getJS()
|
private function getJS()
|
||||||
{
|
{
|
||||||
$javaScript = '<script language="javascript">
|
$javaScript = '<script language="javascript">
|
||||||
@ -479,6 +492,7 @@ class Listview
|
|||||||
|
|
||||||
return $javaScript;
|
return $javaScript;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $TParam
|
* @param $TParam
|
||||||
@ -595,7 +609,7 @@ class Listview
|
|||||||
$TExport = $this->setExport($TParam, $TField, $THeader);
|
$TExport = $this->setExport($TParam, $TField, $THeader);
|
||||||
$TField = $this->addTotalGroup($TField,$TTotalGroup);
|
$TField = $this->addTotalGroup($TField,$TTotalGroup);
|
||||||
|
|
||||||
$out = $this->getJS();
|
//$out = $this->getJS();
|
||||||
|
|
||||||
$dolibarr_decalage = $this->totalRow > $this->totalRowToShow ? 1 : 0;
|
$dolibarr_decalage = $this->totalRow > $this->totalRowToShow ? 1 : 0;
|
||||||
ob_start();
|
ob_start();
|
||||||
@ -605,6 +619,26 @@ class Listview
|
|||||||
|
|
||||||
$out.= '<table id="'.$this->id.'" class="liste" width="100%"><thead>';
|
$out.= '<table id="'.$this->id.'" class="liste" width="100%"><thead>';
|
||||||
|
|
||||||
|
if(count($TSearch)>0)
|
||||||
|
{
|
||||||
|
$out.='<tr class="liste_titre liste_titre_search barre-recherche">';
|
||||||
|
|
||||||
|
foreach ($THeader as $field => $head)
|
||||||
|
{
|
||||||
|
if ($field === 'selectedfields')
|
||||||
|
{
|
||||||
|
$out.= '<td class="liste_titre" align="right">'.$this->form->showFilterAndCheckAddButtons(0).'</td>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$moreattrib = 'style="width:'.$head['width'].';text-align:'.$head['text-align'].'"';
|
||||||
|
$out .= '<td class="liste_titre" '.$moreattrib.'>'.$TSearch[$field].'</td>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$out.='</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
$out.= '<tr class="liste_titre">';
|
$out.= '<tr class="liste_titre">';
|
||||||
foreach($THeader as $field => $head)
|
foreach($THeader as $field => $head)
|
||||||
{
|
{
|
||||||
@ -635,31 +669,11 @@ class Listview
|
|||||||
//$out .= '<th aligne="right" class="maxwidthsearch liste_titre">--</th>';
|
//$out .= '<th aligne="right" class="maxwidthsearch liste_titre">--</th>';
|
||||||
$out .= '</tr>';
|
$out .= '</tr>';
|
||||||
|
|
||||||
if(count($TSearch)>0)
|
|
||||||
{
|
|
||||||
$out.='<tr class="liste_titre barre-recherche">';
|
|
||||||
|
|
||||||
foreach ($THeader as $field => $head)
|
|
||||||
{
|
|
||||||
if ($field === 'selectedfields')
|
|
||||||
{
|
|
||||||
$out.= '<td class="liste_titre" align="right">'.$this->form->showFilterAndCheckAddButtons(0).'</td>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$moreattrib = 'style="width:'.$head['width'].';text-align:'.$head['text-align'].'"';
|
|
||||||
$out .= '<td class="liste_titre" '.$moreattrib.'>'.$TSearch[$field].'</td>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$out.='</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$out.='</thead><tbody>';
|
$out.='</thead><tbody>';
|
||||||
|
|
||||||
if(empty($TField))
|
if(empty($TField))
|
||||||
{
|
{
|
||||||
if (!empty($TParam['list']['messageNothing'])) $out .= '<tr class="pair" align="center"><td colspan="'.(count($TParam['title'])+1).'">'.$TParam['list']['messageNothing'].'</td></tr>';
|
if (!empty($TParam['list']['messageNothing'])) $out .= '<tr class="oddeven"><td colspan="'.(count($TParam['title'])+1).'"><span class="opacitymedium">'.$TParam['list']['messageNothing'].'</span></td></tr>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -729,27 +743,6 @@ class Listview
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $sql
|
|
||||||
* @param $TParam
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function order_by($sql, &$TParam)
|
|
||||||
{
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
if (!empty($TParam['sortfield']))
|
|
||||||
{
|
|
||||||
if(strpos($sql,'LIMIT ') !== false) list($sql, $sqlLIMIT) = explode('LIMIT ', $sql);
|
|
||||||
|
|
||||||
$sql .= $db->order($TParam['sortfield'], $TParam['sortorder']);
|
|
||||||
|
|
||||||
if (!empty($sqlLIMIT)) $sql .= ' LIMIT '.$sqlLIMIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sql;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $THeader
|
* @param $THeader
|
||||||
* @param $TField
|
* @param $TField
|
||||||
|
|||||||
@ -1,3 +1,23 @@
|
|||||||
|
// Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
// or see http://www.gnu.org/
|
||||||
|
|
||||||
|
//
|
||||||
|
// \file htdocs/core/js/listview.js
|
||||||
|
// \brief File that include javascript functions for lists
|
||||||
|
//
|
||||||
var Listview_include = true;
|
var Listview_include = true;
|
||||||
|
|
||||||
function Listview_OrderDown(idListe, column) {
|
function Listview_OrderDown(idListe, column) {
|
||||||
|
|||||||
@ -1253,6 +1253,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inventory
|
// Inventory
|
||||||
|
if ($conf->global->MAIN_LEVEL_FEATURES >= 2)
|
||||||
|
{
|
||||||
if (! empty($conf->stock->enabled))
|
if (! empty($conf->stock->enabled))
|
||||||
{
|
{
|
||||||
$langs->load("stocks");
|
$langs->load("stocks");
|
||||||
@ -1260,6 +1262,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
|||||||
$newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->creer);
|
$newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->creer);
|
||||||
$newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->lire);
|
$newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->lire);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Expeditions
|
// Expeditions
|
||||||
if (! empty($conf->expedition->enabled))
|
if (! empty($conf->expedition->enabled))
|
||||||
|
|||||||
@ -146,9 +146,7 @@ ProductStockWarehouseUpdated=Stock limit for alert and desired optimal stock cor
|
|||||||
ProductStockWarehouseDeleted=Stock limit for alert and desired optimal stock correctly deleted
|
ProductStockWarehouseDeleted=Stock limit for alert and desired optimal stock correctly deleted
|
||||||
AddNewProductStockWarehouse=Set new limit for alert and desired optimal stock
|
AddNewProductStockWarehouse=Set new limit for alert and desired optimal stock
|
||||||
AddStockLocationLine=Decrease quantity then click to add another warehouse for this product
|
AddStockLocationLine=Decrease quantity then click to add another warehouse for this product
|
||||||
|
InventoryDate=Inventory date
|
||||||
Module104420Name = Inventory
|
|
||||||
Module104420Desc = Create and manage your inventory
|
|
||||||
NewInventory=New inventory
|
NewInventory=New inventory
|
||||||
inventorySetup = Inventory Setup
|
inventorySetup = Inventory Setup
|
||||||
inventoryCreatePermission=Create new inventory
|
inventoryCreatePermission=Create new inventory
|
||||||
|
|||||||
@ -109,9 +109,9 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Action to add record
|
// Action to add record
|
||||||
if ($action == 'add')
|
if ($action == 'add' && ! empty($user->rights->mymodule->create))
|
||||||
{
|
{
|
||||||
if (GETPOST('cancel'))
|
if ($cancel)
|
||||||
{
|
{
|
||||||
$urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1);
|
$urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1);
|
||||||
header("Location: ".$urltogo);
|
header("Location: ".$urltogo);
|
||||||
@ -154,7 +154,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Action to update record
|
// Action to update record
|
||||||
if ($action == 'update')
|
if ($action == 'update' && ! empty($user->rights->mymodule->create))
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Action to delete
|
// Action to delete
|
||||||
if ($action == 'confirm_delete')
|
if ($action == 'confirm_delete' && ! empty($user->rights->mymodule->delete))
|
||||||
{
|
{
|
||||||
$result=$object->delete($user);
|
$result=$object->delete($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
@ -216,10 +216,10 @@ if (empty($reshook))
|
|||||||
* Put here all code to build page
|
* Put here all code to build page
|
||||||
****************************************************/
|
****************************************************/
|
||||||
|
|
||||||
llxHeader('','MyPageName','');
|
|
||||||
|
|
||||||
$form=new Form($db);
|
$form=new Form($db);
|
||||||
|
|
||||||
|
llxHeader('','MyPageName','');
|
||||||
|
|
||||||
|
|
||||||
// Put here content of your page
|
// Put here content of your page
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require '../../main.inc.php';
|
require '../../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/inventory/class/inventory.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php';
|
||||||
|
|
||||||
$get = GETPOST('get');
|
$get = GETPOST('get');
|
||||||
$put = GETPOST('put');
|
$put = GETPOST('put');
|
||||||
|
|||||||
@ -32,116 +32,147 @@ include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||||
|
|
||||||
|
|
||||||
$langs->load('stock');
|
$langs->load('stock');
|
||||||
$langs->load('inventory');
|
$langs->load('inventory');
|
||||||
|
|
||||||
if(empty($user->rights->stock->read)) accessforbidden();
|
$id=GETPOST('id', 'int');
|
||||||
|
$ref=GETPOST('ref', 'alpha');
|
||||||
|
$action=(GETPOST('action','alpha') ? GETPOST('action','alpha') : 'view');
|
||||||
|
$cancel=GETPOST('cancel');
|
||||||
|
$confirm=GETPOST('confirm','alpha');
|
||||||
|
$socid=GETPOST('socid','int');
|
||||||
|
if (! empty($user->societe_id)) $socid=$user->societe_id;
|
||||||
|
|
||||||
_action();
|
if (empty($action) && empty($id) && empty($ref)) $action='view';
|
||||||
|
|
||||||
function _action()
|
// Protection if external user
|
||||||
|
if ($user->societe_id > 0)
|
||||||
{
|
{
|
||||||
global $user, $db, $conf, $langs;
|
//accessforbidden();
|
||||||
|
}
|
||||||
|
$result = restrictedArea($user, 'stock', $id);
|
||||||
|
|
||||||
/*******************************************************************
|
|
||||||
* ACTIONS
|
|
||||||
*
|
|
||||||
* Put here all code to do according to value of "action" parameter
|
|
||||||
********************************************************************/
|
|
||||||
|
|
||||||
$action=GETPOST('action');
|
$object = new Inventory($db);
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
switch($action) {
|
// fetch optionals attributes and labels
|
||||||
case 'create':
|
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
if (empty($user->rights->stock->create)) accessforbidden();
|
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
// Load object
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||||
|
|
||||||
card_warehouse( $inventory);
|
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
|
||||||
|
$hookmanager->initHooks(array('inventory'));
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'confirmCreate':
|
|
||||||
if (empty($user->rights->stock->create)) accessforbidden();
|
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
/*
|
||||||
$inventory->setValues($_POST);
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
$fk_inventory = $inventory->create($user);
|
$parameters=array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas);
|
||||||
if($fk_inventory>0) {
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
|
if ($cancel)
|
||||||
|
{
|
||||||
|
if ($action != 'addlink')
|
||||||
|
{
|
||||||
|
$urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1);
|
||||||
|
header("Location: ".$urltogo);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref);
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'confirmCreate')
|
||||||
|
{
|
||||||
|
if (empty($user->rights->stock->creer)) accessforbidden();
|
||||||
|
|
||||||
|
if ($cancel)
|
||||||
|
{
|
||||||
|
$urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1);
|
||||||
|
header("Location: ".$urltogo);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
$object->setValues($_POST);
|
||||||
|
|
||||||
|
$fk_inventory = $object->create($user);
|
||||||
|
if ($fk_inventory>0)
|
||||||
|
{
|
||||||
$fk_category = (int) GETPOST('fk_category');
|
$fk_category = (int) GETPOST('fk_category');
|
||||||
$fk_supplier = (int) GETPOST('fk_supplier');
|
$fk_supplier = (int) GETPOST('fk_supplier');
|
||||||
$fk_warehouse = (int) GETPOST('fk_warehouse');
|
$fk_warehouse = (int) GETPOST('fk_warehouse');
|
||||||
$only_prods_in_stock = (int) GETPOST('OnlyProdsInStock');
|
$only_prods_in_stock = (int) GETPOST('OnlyProdsInStock');
|
||||||
|
|
||||||
$inventory->addProductsFor($fk_warehouse,$fk_category,$fk_supplier,$only_prods_in_stock);
|
$object->addProductsFor($fk_warehouse,$fk_category,$fk_supplier,$only_prods_in_stock);
|
||||||
$inventory->update($user);
|
$object->update($user);
|
||||||
|
|
||||||
header('Location: '.dol_buildpath('/product/inventory/card.php?id='.$inventory->id.'&action=edit', 1));
|
|
||||||
|
|
||||||
|
header('Location: '.dol_buildpath('/product/inventory/card.php?id='.$object->id.'&action=edit', 1));
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
setEventMessage($inventory->error,'errors');
|
setEventMessage($object->error,'errors');
|
||||||
header('Location: '.dol_buildpath('/product/inventory/card.php?action=create', 1));
|
header('Location: '.dol_buildpath('/product/inventory/card.php?action=create', 1));
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'edit':
|
switch($action) {
|
||||||
if (!$user->rights->stock->write) accessforbidden();
|
|
||||||
|
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
|
||||||
$inventory->fetch(GETPOST('id'));
|
|
||||||
|
|
||||||
card($inventory, GETPOST('action'));
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'save':
|
case 'save':
|
||||||
if (!$user->rights->stock->write) accessforbidden();
|
if (!$user->rights->stock->creer) accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
$id = GETPOST('id');
|
$id = GETPOST('id');
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
$object = new Inventory($db);
|
||||||
$inventory->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
$inventory->setValues($_REQUEST);
|
$object->setValues($_REQUEST);
|
||||||
|
|
||||||
if ($inventory->errors)
|
if ($object->errors)
|
||||||
{
|
{
|
||||||
setEventMessage($inventory->errors, 'errors');
|
setEventMessage($object->errors, 'errors');
|
||||||
card( $inventory, 'edit');
|
card( $object, 'edit');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$inventory->udpate($user);
|
$object->udpate($user);
|
||||||
header('Location: '.dol_buildpath('/product/inventory/card.php?id='.$inventory->getId().'&action=view', 1));
|
header('Location: '.dol_buildpath('/product/inventory/card.php?id='.$object->getId().'&action=view', 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'confirm_regulate':
|
case 'confirm_regulate':
|
||||||
if (!$user->rights->stock->write) accessforbidden();
|
if (!$user->rights->stock->creer) accessforbidden();
|
||||||
$id = GETPOST('id');
|
$id = GETPOST('id');
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
$object = new Inventory($db);
|
||||||
$inventory->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
if($inventory->status == 0) {
|
if($object->status == 0) {
|
||||||
$inventory->status = 1;
|
$object->status = 1;
|
||||||
$inventory->update($user);
|
$object->update($user);
|
||||||
|
|
||||||
card( $inventory, 'view');
|
card( $object, 'view');
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
card( $inventory, 'view');
|
card( $object, 'view');
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -150,23 +181,23 @@ function _action()
|
|||||||
|
|
||||||
$id = GETPOST('id');
|
$id = GETPOST('id');
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
$object = new Inventory($db);
|
||||||
$inventory->fetch( $id );
|
$object->fetch( $id );
|
||||||
|
|
||||||
$inventory->changePMP($user);
|
$object->changePMP($user);
|
||||||
|
|
||||||
card( $inventory, 'view');
|
card( $object, 'view');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'add_line':
|
case 'add_line':
|
||||||
if (!$user->rights->stock->write) accessforbidden();
|
if (!$user->rights->stock->creer) accessforbidden();
|
||||||
|
|
||||||
$id = GETPOST('id');
|
$id = GETPOST('id');
|
||||||
$fk_warehouse = GETPOST('fk_warehouse');
|
$fk_warehouse = GETPOST('fk_warehouse');
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
$object = new Inventory($db);
|
||||||
$inventory->fetch( $id );
|
$object->fetch( $id );
|
||||||
|
|
||||||
$fk_product = GETPOST('fk_product');
|
$fk_product = GETPOST('fk_product');
|
||||||
if ($fk_product>0)
|
if ($fk_product>0)
|
||||||
@ -179,8 +210,8 @@ function _action()
|
|||||||
|
|
||||||
//Check product not already exists
|
//Check product not already exists
|
||||||
$alreadyExists = false;
|
$alreadyExists = false;
|
||||||
if(!empty($inventory->Inventorydet)) {
|
if(!empty($object->Inventorydet)) {
|
||||||
foreach ($inventory->Inventorydet as $invdet)
|
foreach ($object->Inventorydet as $invdet)
|
||||||
{
|
{
|
||||||
if ($invdet->fk_product == $product->id
|
if ($invdet->fk_product == $product->id
|
||||||
&& $invdet->fk_warehouse == $fk_warehouse)
|
&& $invdet->fk_warehouse == $fk_warehouse)
|
||||||
@ -192,7 +223,7 @@ function _action()
|
|||||||
}
|
}
|
||||||
if (!$alreadyExists)
|
if (!$alreadyExists)
|
||||||
{
|
{
|
||||||
if($inventory->addProduct($product->id, $fk_warehouse)) {
|
if($object->addProduct($product->id, $fk_warehouse)) {
|
||||||
setEventMessage($langs->trans('ProductAdded'));
|
setEventMessage($langs->trans('ProductAdded'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,59 +234,59 @@ function _action()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$inventory->update($user);
|
$object->update($user);
|
||||||
$inventory->sortDet();
|
$object->sortDet();
|
||||||
}
|
}
|
||||||
|
|
||||||
card( $inventory, 'edit');
|
card( $object, 'edit');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'confirm_delete_line':
|
case 'confirm_delete_line':
|
||||||
if (!$user->rights->stock->write) accessforbidden();
|
if (!$user->rights->stock->creer) accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
//Cette action devrais se faire uniquement si le status de l'inventaire est à 0 mais aucune vérif
|
//Cette action devrais se faire uniquement si le status de l'inventaire est à 0 mais aucune vérif
|
||||||
$rowid = GETPOST('rowid');
|
$rowid = GETPOST('rowid');
|
||||||
$Inventorydet = new Inventorydet($db);
|
$objectdet = new Inventorydet($db);
|
||||||
if($Inventorydet->fetch($rowid)>0) {
|
if($objectdet->fetch($rowid)>0) {
|
||||||
$Inventorydet->delete($user);
|
$objectdet->delete($user);
|
||||||
setEventMessage("ProductDeletedFromInventory");
|
setEventMessage("ProductDeletedFromInventory");
|
||||||
}
|
}
|
||||||
$id = GETPOST('id');
|
$id = GETPOST('id');
|
||||||
$inventory = new Inventory($db);
|
$object = new Inventory($db);
|
||||||
$inventory->fetch( $id);
|
$object->fetch( $id);
|
||||||
|
|
||||||
card($inventory, 'edit');
|
card($object, 'edit');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'confirm_flush':
|
case 'confirm_flush':
|
||||||
if (!$user->rights->stock->create) accessforbidden();
|
if (!$user->rights->stock->creer) accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
$id = GETPOST('id');
|
$id = GETPOST('id');
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
$object = new Inventory($db);
|
||||||
$inventory->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
$inventory->deleteAllLine($user);
|
$object->deleteAllLine($user);
|
||||||
|
|
||||||
setEventMessage($langs->trans('InventoryFlushed'));
|
setEventMessage($langs->trans('InventoryFlushed'));
|
||||||
|
|
||||||
card( $inventory, 'edit');
|
card( $object, 'edit');
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'confirm_delete':
|
case 'confirm_delete':
|
||||||
if (!$user->rights->stock->create) accessforbidden();
|
if (!$user->rights->stock->supprimer) accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
$id = GETPOST('id');
|
$id = GETPOST('id');
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
$object = new Inventory($db);
|
||||||
$inventory->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
$inventory->delete($user);
|
$object->delete($user);
|
||||||
|
|
||||||
setEventMessage($langs->trans('InventoryDeleted'));
|
setEventMessage($langs->trans('InventoryDeleted'));
|
||||||
|
|
||||||
@ -263,46 +294,41 @@ function _action()
|
|||||||
exit;
|
exit;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'exportCSV':
|
/*case 'exportCSV':
|
||||||
|
|
||||||
$id = GETPOST('id');
|
$id = GETPOST('id');
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
$object = new Inventory($db);
|
||||||
$inventory->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
_exportCSV($inventory);
|
_exportCSV($object);
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
break;
|
break;
|
||||||
|
*/
|
||||||
default:
|
}
|
||||||
if (!$user->rights->stock->write) accessforbidden();
|
|
||||||
|
|
||||||
$id = GETPOST('id');
|
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
|
||||||
$inventory->fetch($id);
|
|
||||||
|
|
||||||
card($inventory, $action );
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function card_warehouse(&$inventory)
|
/*
|
||||||
|
* Views
|
||||||
|
*/
|
||||||
|
|
||||||
|
$form=new Form($db);
|
||||||
|
|
||||||
|
llxHeader('',$langs->trans('Inventory'),'','');
|
||||||
|
|
||||||
|
if ($action == 'create')
|
||||||
{
|
{
|
||||||
global $langs,$conf,$db, $user, $form;
|
if (empty($user->rights->stock->creer)) accessforbidden();
|
||||||
|
|
||||||
dol_include_once('/categories/class/categorie.class.php');
|
print load_fiche_titre($langs->trans("NewInventory"));
|
||||||
|
|
||||||
llxHeader('',$langs->trans('inventorySelectWarehouse'),'','');
|
|
||||||
print dol_get_fiche_head(inventoryPrepareHead($inventory));
|
|
||||||
|
|
||||||
echo '<form name="confirmCreate" action="'.$_SERVER['PHP_SELF'].'" method="post" />';
|
echo '<form name="confirmCreate" action="'.$_SERVER['PHP_SELF'].'" method="post" />';
|
||||||
echo '<input type="hidden" name="action" value="confirmCreate" />';
|
echo '<input type="hidden" name="action" value="confirmCreate" />';
|
||||||
|
|
||||||
|
dol_fiche_head();
|
||||||
|
|
||||||
$formproduct = new FormProduct($db);
|
$formproduct = new FormProduct($db);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -337,61 +363,63 @@ function card_warehouse(&$inventory)
|
|||||||
</table>
|
</table>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
print '<div class="tabsAction">';
|
dol_fiche_end();
|
||||||
print '<input type="submit" class="butAction" value="'.$langs->trans('inventoryConfirmCreate').'" />';
|
|
||||||
|
print '<div class="center">';
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans('inventoryConfirmCreate').'" />';
|
||||||
|
print ' ';
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans('inventoryConfirmCreate').'" />';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
echo '</form>';
|
echo '</form>';
|
||||||
|
|
||||||
llxFooter('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function card(&$inventory, $action='edit')
|
if ($action == 'view' || $action == 'edit' || empty($action))
|
||||||
{
|
{
|
||||||
global $langs, $conf, $db, $user,$form;
|
$object = new Inventory($db);
|
||||||
|
$object->fetch($id);
|
||||||
llxHeader('',$langs->trans('inventoryEdit'),'','');
|
|
||||||
|
|
||||||
if($action == 'changePMP')
|
if($action == 'changePMP')
|
||||||
{
|
{
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id, $langs->trans('ApplyNewPMP'), $langs->trans('ConfirmApplyNewPMP', $inventory->getTitle()), 'confirm_changePMP', array(),'no',1);
|
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ApplyNewPMP'), $langs->trans('ConfirmApplyNewPMP', $object->getTitle()), 'confirm_changePMP', array(),'no',1);
|
||||||
}
|
}
|
||||||
else if($action == 'flush')
|
else if($action == 'flush')
|
||||||
{
|
{
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id,$langs->trans('FlushInventory'),$langs->trans('ConfirmFlushInventory',$inventory->getTitle()),'confirm_flush',array(),'no',1);
|
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('FlushInventory'),$langs->trans('ConfirmFlushInventory',$object->getTitle()),'confirm_flush',array(),'no',1);
|
||||||
}
|
}
|
||||||
else if($action == 'delete')
|
else if($action == 'delete')
|
||||||
{
|
{
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id,$langs->trans('Delete'),$langs->trans('ConfirmDelete',$inventory->getTitle()),'confirm_delete',array(),'no',1);
|
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('Delete'),$langs->trans('ConfirmDelete',$object->getTitle()),'confirm_delete',array(),'no',1);
|
||||||
}
|
}
|
||||||
else if($action == 'delete_line')
|
else if($action == 'delete_line')
|
||||||
{
|
{
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id.'&rowid='.GETPOST('rowid'),$langs->trans('DeleteLine'),$langs->trans('ConfirmDeleteLine',$inventory->getTitle()),'confirm_delete_line',array(),'no',1);
|
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&rowid='.GETPOST('rowid'),$langs->trans('DeleteLine'),$langs->trans('ConfirmDeleteLine',$object->getTitle()),'confirm_delete_line',array(),'no',1);
|
||||||
}
|
}
|
||||||
else if($action == 'regulate')
|
else if($action == 'regulate')
|
||||||
{
|
{
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id,$langs->trans('RegulateStock'),$langs->trans('ConfirmRegulateStock',$inventory->getTitle()),'confirm_regulate',array(),'no',1);
|
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('RegulateStock'),$langs->trans('ConfirmRegulateStock',$object->getTitle()),'confirm_regulate',array(),'no',1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$warehouse = new Entrepot($db);
|
$warehouse = new Entrepot($db);
|
||||||
$warehouse->fetch($inventory->fk_warehouse);
|
$warehouse->fetch($object->fk_warehouse);
|
||||||
|
|
||||||
print dol_get_fiche_head(inventoryPrepareHead($inventory, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), empty($action) ? '': '&action='.$action));
|
print dol_get_fiche_head(inventoryPrepareHead($object, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), empty($action) ? '': '&action='.$action));
|
||||||
|
|
||||||
$lines = array();
|
$lines = array();
|
||||||
card_line($inventory, $lines, $action);
|
card_line($object, $lines, $action);
|
||||||
|
|
||||||
print '<b>'.$langs->trans('inventoryOnDate')." ".$inventory->getDate('date_inventory').'</b><br><br>';
|
print '<b>'.$langs->trans('inventoryOnDate')." ".$object->getDate('date_inventory').'</b><br><br>';
|
||||||
|
|
||||||
$inventoryTPL = array(
|
$objectTPL = array(
|
||||||
'id'=> $inventory->id
|
'id'=> $object->id
|
||||||
,'date_cre' => $inventory->getDate('date_cre', 'd/m/Y')
|
,'date_cre' => $object->getDate('date_cre', 'd/m/Y')
|
||||||
,'date_maj' => $inventory->getDate('date_maj', 'd/m/Y H:i')
|
,'date_maj' => $object->getDate('date_maj', 'd/m/Y H:i')
|
||||||
,'fk_warehouse' => $inventory->fk_warehouse
|
,'fk_warehouse' => $object->fk_warehouse
|
||||||
,'status' => $inventory->status
|
,'status' => $object->status
|
||||||
,'entity' => $inventory->entity
|
,'entity' => $object->entity
|
||||||
,'amount' => price( round($inventory->amount,2) )
|
,'amount' => price( round($object->amount,2) )
|
||||||
,'amount_actual'=>price (round($inventory->amount_actual,2))
|
,'amount_actual'=>price (round($object->amount_actual,2))
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -402,15 +430,18 @@ function card(&$inventory, $action='edit')
|
|||||||
'mode' => $action
|
'mode' => $action
|
||||||
,'url' => dol_buildpath('/product/inventory/card.php', 1)
|
,'url' => dol_buildpath('/product/inventory/card.php', 1)
|
||||||
,'can_validate' => (int) $user->rights->stock->validate
|
,'can_validate' => (int) $user->rights->stock->validate
|
||||||
,'is_already_validate' => (int) $inventory->status
|
,'is_already_validate' => (int) $object->status
|
||||||
,'token'=>$_SESSION['newtoken']
|
,'token'=>$_SESSION['newtoken']
|
||||||
);
|
);
|
||||||
|
|
||||||
include './tpl/inventory.tpl.php';
|
include './tpl/inventory.tpl.php';
|
||||||
|
|
||||||
llxFooter('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// End of page
|
||||||
|
llxFooter();
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function card_line(&$inventory, &$lines, $mode)
|
function card_line(&$inventory, &$lines, $mode)
|
||||||
{
|
{
|
||||||
@ -421,7 +452,6 @@ function card_line(&$inventory, &$lines, $mode)
|
|||||||
|
|
||||||
foreach ($inventory->Inventorydet as $k => $Inventorydet)
|
foreach ($inventory->Inventorydet as $k => $Inventorydet)
|
||||||
{
|
{
|
||||||
|
|
||||||
$product = & $Inventorydet->product;
|
$product = & $Inventorydet->product;
|
||||||
$stock = $Inventorydet->qty_stock;
|
$stock = $Inventorydet->qty_stock;
|
||||||
|
|
||||||
@ -442,7 +472,7 @@ function card_line(&$inventory, &$lines, $mode)
|
|||||||
'produit' => $product->getNomUrl(1).' - '.$product->label,
|
'produit' => $product->getNomUrl(1).' - '.$product->label,
|
||||||
'entrepot'=>$e->getNomUrl(1),
|
'entrepot'=>$e->getNomUrl(1),
|
||||||
'barcode' => $product->barcode,
|
'barcode' => $product->barcode,
|
||||||
'qty' =>($mode == 'edit' ? '<input type="text" name="qty_to_add['.$k.']" value="'.$qty.'" size="8" style="text-align:center;" /> <a id="a_save_qty_'.$k.'" href="javascript:save_qty('.$k.')">'.img_picto($langs->trans('Add'), 'plus16@inventory').'</a>' : '' ),
|
'qty' =>($mode == 'edit' ? '<input type="text" name="qty_to_add['.$k.']" value="'.$qty.'" size="8" style="text-align:center;" /> <a id="a_save_qty_'.$k.'" href="javascript:save_qty('.$k.')">'.img_picto($langs->trans('Add'), 'edit_add').'</a>' : '' ),
|
||||||
'qty_view' => ($Inventorydet->qty_view ? $Inventorydet->qty_view : 0),
|
'qty_view' => ($Inventorydet->qty_view ? $Inventorydet->qty_view : 0),
|
||||||
'qty_stock' => $stock,
|
'qty_stock' => $stock,
|
||||||
'qty_regulated' => ($Inventorydet->qty_regulated ? $Inventorydet->qty_regulated : 0),
|
'qty_regulated' => ($Inventorydet->qty_regulated ? $Inventorydet->qty_regulated : 0),
|
||||||
@ -461,7 +491,10 @@ function card_line(&$inventory, &$lines, $mode)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _exportCSV(&$inventory) {
|
|
||||||
|
/*
|
||||||
|
function _exportCSV(&$inventory)
|
||||||
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
header('Content-Type: application/octet-stream');
|
header('Content-Type: application/octet-stream');
|
||||||
@ -531,8 +564,10 @@ function _exportCSV(&$inventory) {
|
|||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
function _footerList($view,$total_pmp,$total_pmp_actual,$total_pa,$total_pa_actual, $total_current_pa,$total_current_pa_actual) {
|
function _footerList($view,$total_pmp,$total_pmp_actual,$total_pa,$total_pa_actual, $total_current_pa,$total_current_pa_actual)
|
||||||
|
{
|
||||||
global $conf,$user,$langs;
|
global $conf,$user,$langs;
|
||||||
|
|
||||||
if ($view['can_validate'] == 1) { ?>
|
if ($view['can_validate'] == 1) { ?>
|
||||||
@ -569,7 +604,10 @@ function _footerList($view,$total_pmp,$total_pmp_actual,$total_pa,$total_pa_actu
|
|||||||
</tr>
|
</tr>
|
||||||
<?php }
|
<?php }
|
||||||
}
|
}
|
||||||
function _headerList($view) {
|
|
||||||
|
|
||||||
|
function _headerList($view)
|
||||||
|
{
|
||||||
global $conf,$user,$langs;
|
global $conf,$user,$langs;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -67,7 +67,7 @@ class Inventory extends CoreObject
|
|||||||
* Attribute object linked with database
|
* Attribute object linked with database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $__fields=array(
|
protected $fields=array(
|
||||||
'fk_warehouse'=>array('type'=>'integer','index'=>true)
|
'fk_warehouse'=>array('type'=>'integer','index'=>true)
|
||||||
,'entity'=>array('type'=>'integer','index'=>true)
|
,'entity'=>array('type'=>'integer','index'=>true)
|
||||||
,'status'=>array('type'=>'integer','index'=>true)
|
,'status'=>array('type'=>'integer','index'=>true)
|
||||||
@ -503,6 +503,7 @@ class Inventory extends CoreObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to get the sql select of inventory
|
* Function to get the sql select of inventory
|
||||||
|
*
|
||||||
* @param string $type 'All' to get all data
|
* @param string $type 'All' to get all data
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -516,7 +517,7 @@ class Inventory extends CoreObject
|
|||||||
$sql = 'SELECT i.rowid,i.title, e.label, i.date_inventory, i.fk_warehouse, i.datec, i.tms, i.status';
|
$sql = 'SELECT i.rowid,i.title, e.label, i.date_inventory, i.fk_warehouse, i.datec, i.tms, i.status';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'inventory i';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'inventory i';
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot e ON (e.rowid = i.fk_warehouse)';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot e ON (e.rowid = i.fk_warehouse)';
|
||||||
$sql.= ' WHERE i.entity = '.(int) $conf->entity;
|
$sql.= ' WHERE i.entity IN ('.getEntity('inventory', 1).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
@ -541,7 +542,7 @@ class Inventorydet extends CoreObject
|
|||||||
public $pa;
|
public $pa;
|
||||||
public $new_pmp;
|
public $new_pmp;
|
||||||
|
|
||||||
protected $__fields=array(
|
protected $fields=array(
|
||||||
'fk_inventory'=>array('type'=>'int')
|
'fk_inventory'=>array('type'=>'int')
|
||||||
,'fk_warehouse'=>array('type'=>'int')
|
,'fk_warehouse'=>array('type'=>'int')
|
||||||
,'fk_product'=>array('type'=>'int')
|
,'fk_product'=>array('type'=>'int')
|
||||||
|
|||||||
@ -36,7 +36,30 @@ require_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php';
|
|||||||
$langs->load("stock");
|
$langs->load("stock");
|
||||||
$langs->load("inventory");
|
$langs->load("inventory");
|
||||||
|
|
||||||
if (empty($user->rights->stock->read)) accessforbidden();
|
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
|
||||||
|
$sortfield = GETPOST("sortfield",'alpha');
|
||||||
|
$sortorder = GETPOST("sortorder",'alpha');
|
||||||
|
$page = (GETPOST("page",'int')?GETPOST("page", 'int'):0);
|
||||||
|
if ($page == -1) { $page = 0; }
|
||||||
|
$offset = $limit * $page;
|
||||||
|
$pageprev = $page - 1;
|
||||||
|
$pagenext = $page + 1;
|
||||||
|
if (! $sortfield) $sortfield="i.title";
|
||||||
|
if (! $sortorder) $sortorder="ASC";
|
||||||
|
|
||||||
|
if (empty($user->rights->stock->lire)) accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
|
// None
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
llxHeader('',$langs->trans('inventoryListTitle'),'','');
|
llxHeader('',$langs->trans('inventoryListTitle'),'','');
|
||||||
|
|
||||||
@ -48,8 +71,15 @@ $list = new ListView($db, 'listInventory');
|
|||||||
$THide = array('label','title');
|
$THide = array('label','title');
|
||||||
|
|
||||||
echo $list->render(Inventory::getSQL('All'), array(
|
echo $list->render(Inventory::getSQL('All'), array(
|
||||||
|
'param' => array(
|
||||||
|
'limit' => $limit,
|
||||||
|
'offset' => $offset,
|
||||||
|
'sortfield' => $sortfield,
|
||||||
|
'sortorder'=> $sortorder,
|
||||||
|
'page'=>$page
|
||||||
|
),
|
||||||
'limit' => array(
|
'limit' => array(
|
||||||
'nbLine' => GETPOST('limit')
|
'nbLine' => $limit,
|
||||||
),
|
),
|
||||||
'allow-field-select' => true,
|
'allow-field-select' => true,
|
||||||
'link'=>array(
|
'link'=>array(
|
||||||
@ -65,14 +95,14 @@ 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'
|
'image' => 'title_products.png'
|
||||||
),
|
),
|
||||||
'title'=>array(
|
'title'=>array(
|
||||||
'rowid'=>$langs->trans('Title'),
|
'rowid'=>$langs->trans('Title'),
|
||||||
'date_inventory'=>$langs->trans('InventoryDate'),
|
'date_inventory'=>$langs->trans('InventoryDate'),
|
||||||
'datec'=>$langs->trans('DateCreation'),
|
|
||||||
'fk_warehouse'=>$langs->trans('Warehouse'),
|
'fk_warehouse'=>$langs->trans('Warehouse'),
|
||||||
'tms'=>$langs->trans('DateUpdate'),
|
'datec'=>$langs->trans('DateCreation'),
|
||||||
|
'tms'=>$langs->trans('DateModification'),
|
||||||
'status'=>$langs->trans('Status')
|
'status'=>$langs->trans('Status')
|
||||||
),
|
),
|
||||||
'eval'=>array(
|
'eval'=>array(
|
||||||
|
|||||||
@ -71,15 +71,15 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php if ($inventory->status != 1) { ?>
|
<?php if ($object->status != 1) { ?>
|
||||||
<strong><?php echo $langs->trans('AddInventoryProduct'); ?> : </strong>
|
<strong><?php echo $langs->trans('AddInventoryProduct'); ?> : </strong>
|
||||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
|
||||||
<input type="hidden" name="action" value="add_line" />
|
<input type="hidden" name="action" value="add_line" />
|
||||||
<input type="hidden" name="id" value="<?php echo $inventory->id; ?>" />
|
<input type="hidden" name="id" value="<?php echo $object->id; ?>" />
|
||||||
|
|
||||||
<?php echo inventorySelectProducts($inventory); ?>
|
<?php echo inventorySelectProducts($object); ?>
|
||||||
|
|
||||||
<input class="butAction" type="submit" value="<?php echo $langs->trans('AddProduct'); ?>" />
|
<input class="button" type="submit" value="<?php echo $langs->trans('AddProduct'); ?>" />
|
||||||
</form>
|
</form>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
@ -90,7 +90,7 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<input type="hidden" name="action" value="save" />
|
<input type="hidden" name="action" value="save" />
|
||||||
<input type="hidden" name="id" value="<?php echo $inventory->id; ?>" />
|
<input type="hidden" name="id" value="<?php echo $object->id; ?>" />
|
||||||
|
|
||||||
<table width="100%" class="border workstation">
|
<table width="100%" class="border workstation">
|
||||||
<?php
|
<?php
|
||||||
@ -163,43 +163,43 @@
|
|||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<?php if ($inventory->status != 1) { ?>
|
<?php if ($object->status != 1) { ?>
|
||||||
<div class="tabsAction" style="height:30px;">
|
<div class="tabsAction" style="height:30px;">
|
||||||
<?php if ($action!= 'edit') { ?>
|
<?php if ($action!= 'edit') { ?>
|
||||||
<a href="<?php echo $view_url; ?>?id=<?php echo $inventory->id; ?>&action=exportCSV" class="butAction"><?php echo $langs->trans('ExportCSV') ?></a>
|
<!-- <a href="<?php echo $view_url; ?>?id=<?php echo $object->id; ?>&action=exportCSV" class="butAction"><?php echo $langs->trans('ExportCSV') ?></a> -->
|
||||||
<a href="<?php echo $view_url; ?>?id=<?php echo $inventory->id; ?>&action=edit" class="butAction"><?php echo $langs->trans('Modify') ?></a>
|
<a href="<?php echo $view_url; ?>?id=<?php echo $object->id; ?>&action=edit" class="butAction"><?php echo $langs->trans('Modify') ?></a>
|
||||||
<?php
|
<?php
|
||||||
if(!empty($user->rights->stock->changePMP)) {
|
if(!empty($user->rights->stock->changePMP)) {
|
||||||
echo '<a href="'.$view_url.'?id='.$inventory->id.'&action=changePMP" class="butAction">'.$langs->trans('ApplyPMP').'</a>';
|
echo '<a href="'.$view_url.'?id='.$object->id.'&action=changePMP" class="butAction">'.$langs->trans('ApplyPMP').'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($can_validate == 1) { ?>
|
if ($can_validate == 1) { ?>
|
||||||
<a href="<?php echo $view_url; ?>?id=<?php echo $inventory->id; ?>&action=regulate&token=" class="butAction"><?php echo $langs->trans('RegulateStock') ?></a>
|
<a href="<?php echo $view_url; ?>?id=<?php echo $object->id; ?>&action=regulate&token=" class="butAction"><?php echo $langs->trans('RegulateStock') ?></a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($action == 'edit') { ?>
|
<?php if ($action == 'edit') { ?>
|
||||||
<input name="back" type="button" class="butAction" value="<?php echo $langs->trans('ExitEditMode'); ?>" onclick="document.location='?id=<?php echo $inventory->id; ?>&action=view';" />
|
<input name="back" type="button" class="butAction" value="<?php echo $langs->trans('ExitEditMode'); ?>" onclick="document.location='?id=<?php echo $object->id; ?>&action=view';" />
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($can_validate == 1) { ?>
|
<?php if ($can_validate == 1) { ?>
|
||||||
<a href="<?php echo $view_url; ?>?id=<?php echo $inventory->id; ?>&action=flush" class="butActionDelete"><?php echo $langs->trans('Flush'); ?></a>
|
<a href="<?php echo $view_url; ?>?id=<?php echo $object->id; ?>&action=flush" class="butActionDelete"><?php echo $langs->trans('Flush'); ?></a>
|
||||||
|
|
||||||
<a href="<?php echo $view_url; ?>?id=<?php echo $inventory->id; ?>&action=delete" class="butActionDelete"><?php echo $langs->trans('Delete') ?></a>
|
<a href="<?php echo $view_url; ?>?id=<?php echo $object->id; ?>&action=delete" class="butActionDelete"><?php echo $langs->trans('Delete') ?></a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($inventory->status == 1) { ?>
|
<?php if ($object->status == 1) { ?>
|
||||||
<div class="tabsAction">
|
<div class="tabsAction">
|
||||||
<?php if ($can_validate == 1) { ?>
|
<?php if ($can_validate == 1) { ?>
|
||||||
|
|
||||||
<a href="<?php echo $view_url; ?>?id=<?php echo $inventory->id; ?>&action=exportCSV" class="butAction"><?php echo $langs->trans('ExportCSV') ?></a>
|
<!-- <a href="<?php echo $view_url; ?>?id=<?php echo $object->id; ?>&action=exportCSV" class="butAction"><?php echo $langs->trans('ExportCSV') ?></a> -->
|
||||||
<a href="#" title="<?php echo $langs->trans('InventoryAlreadyValidated'); ?>" class="butActionRefused"><?php echo $langs->trans('Delete') ?></a>
|
<a href="#" title="<?php echo $langs->trans('InventoryAlreadyValidated'); ?>" class="butActionRefused"><?php echo $langs->trans('Delete') ?></a>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</form>
|
</form>
|
||||||
<p>Date de création : <?php echo $inventory->getDate('datec') ?>
|
<p>Date de création : <?php echo $object->getDate('datec') ?>
|
||||||
<br />Dernière mise à jour : <?php echo $inventory->getDate('tms') ?></p>
|
<br />Dernière mise à jour : <?php echo $object->getDate('tms') ?></p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user