fix
This commit is contained in:
parent
81b01cd055
commit
9f6f874655
@ -158,7 +158,7 @@ class CoreObject extends CommonObject {
|
|||||||
$query[$field] = $this->date_0;
|
$query[$field] = $this->date_0;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$query[$field] = $this->db->jdate($this->{$field});
|
$query[$field] = $this->db->idate($this->{$field});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if($this->is_array($info)){
|
else if($this->is_array($info)){
|
||||||
@ -427,7 +427,6 @@ class CoreObject extends CommonObject {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
|
|
||||||
$this->{$field} = dol_stringtotime($date);
|
$this->{$field} = dol_stringtotime($date);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,6 +434,7 @@ class CoreObject extends CommonObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function set_values(&$Tab) {
|
public function set_values(&$Tab) {
|
||||||
|
|
||||||
foreach ($Tab as $key=>$value) {
|
foreach ($Tab as $key=>$value) {
|
||||||
|
|
||||||
if($this->checkFieldType($key,'date')) {
|
if($this->checkFieldType($key,'date')) {
|
||||||
|
|||||||
@ -71,8 +71,9 @@ class Inventory extends CoreObject
|
|||||||
|
|
||||||
public $db;
|
public $db;
|
||||||
|
|
||||||
function __construct(DoliDB &$db)
|
public function __construct(DoliDB &$db)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$this->db = &$db;
|
$this->db = &$db;
|
||||||
|
|
||||||
@ -85,13 +86,13 @@ class Inventory extends CoreObject
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function sort_det()
|
private function sort_det()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!empty($this->Inventorydet)) usort($this->Inventorydet, array('Inventory', 'customSort'));
|
if(!empty($this->Inventorydet)) usort($this->Inventorydet, array('Inventory', 'customSort'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch($id,$annexe = true)
|
public function fetch($id,$annexe = true)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!$annexe) $this->withChild = false;
|
if(!$annexe) $this->withChild = false;
|
||||||
@ -115,7 +116,7 @@ class Inventory extends CoreObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function customSort(&$objA, &$objB)
|
private function customSort(&$objA, &$objB)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
@ -128,7 +129,7 @@ class Inventory extends CoreObject
|
|||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function changePMP() {
|
public function changePMP() {
|
||||||
|
|
||||||
foreach ($this->Inventorydet as $k => &$Inventorydet)
|
foreach ($this->Inventorydet as $k => &$Inventorydet)
|
||||||
{
|
{
|
||||||
@ -147,7 +148,7 @@ class Inventory extends CoreObject
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update(User &$user)
|
public function update(User &$user)
|
||||||
{
|
{
|
||||||
|
|
||||||
//si on valide l'inventaire on sauvegarde le stock à cette instant
|
//si on valide l'inventaire on sauvegarde le stock à cette instant
|
||||||
@ -159,7 +160,7 @@ class Inventory extends CoreObject
|
|||||||
parent::update($user);
|
parent::update($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_values(&$Tab)
|
public function set_values(&$Tab)
|
||||||
{
|
{
|
||||||
global $db,$langs;
|
global $db,$langs;
|
||||||
|
|
||||||
@ -186,19 +187,19 @@ class Inventory extends CoreObject
|
|||||||
parent::set_values($Tab);
|
parent::set_values($Tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteAllLine() {
|
public function deleteAllLine(User &$user) {
|
||||||
|
|
||||||
foreach($this->Inventorydet as &$det) {
|
foreach($this->Inventorydet as &$det) {
|
||||||
$det->to_delete = true;
|
$det->to_delete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->update();
|
$this->update($user);
|
||||||
|
|
||||||
$this->Inventorydet=array();
|
$this->Inventorydet=array();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_product($fk_product, $fk_entrepot='') {
|
public function add_product($fk_product, $fk_entrepot='') {
|
||||||
|
|
||||||
$k = $this->addChild('Inventorydet');
|
$k = $this->addChild('Inventorydet');
|
||||||
$det = &$this->Inventorydet[$k];
|
$det = &$this->Inventorydet[$k];
|
||||||
@ -215,7 +216,7 @@ class Inventory extends CoreObject
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function correct_stock($fk_product, $fk_warehouse, $nbpiece, $movement, $label='', $price=0, $inventorycode='')
|
public function correct_stock($fk_product, $fk_warehouse, $nbpiece, $movement, $label='', $price=0, $inventorycode='')
|
||||||
{
|
{
|
||||||
global $conf, $db, $langs, $user;
|
global $conf, $db, $langs, $user;
|
||||||
|
|
||||||
@ -250,7 +251,7 @@ class Inventory extends CoreObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function regulate()
|
public function regulate()
|
||||||
{
|
{
|
||||||
global $db,$user,$langs,$conf;
|
global $db,$user,$langs,$conf;
|
||||||
|
|
||||||
@ -312,6 +313,36 @@ class Inventory extends CoreObject
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function add_products_for($fk_warehouse,$fk_category=0,$fk_supplier=0,$only_prods_in_stock=0) {
|
||||||
|
$e = new Entrepot($this->db);
|
||||||
|
$e->fetch($fk_warehouse);
|
||||||
|
$TChildWarehouses = array($fk_warehouse);
|
||||||
|
$e->get_children_warehouses($fk_warehouse, $TChildWarehouses);
|
||||||
|
|
||||||
|
$sql = 'SELECT ps.fk_product, ps.fk_entrepot
|
||||||
|
FROM '.MAIN_DB_PREFIX.'product_stock ps
|
||||||
|
INNER JOIN '.MAIN_DB_PREFIX.'product p ON (p.rowid = ps.fk_product)
|
||||||
|
LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product cp ON (cp.fk_product = p.rowid)
|
||||||
|
LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid)
|
||||||
|
WHERE ps.fk_entrepot IN ('.implode(', ', $TChildWarehouses).')';
|
||||||
|
|
||||||
|
if($fk_category>0) $sql.= " AND cp.fk_categorie=".$fk_category;
|
||||||
|
if($fk_supplier>0) $sql.= " AND pfp.fk_soc=".$fk_supplier;
|
||||||
|
if(!empty($only_prods_in_stock)) $sql.= ' AND ps.reel > 0';
|
||||||
|
|
||||||
|
$sql.=' GROUP BY ps.fk_product, ps.fk_entrepot
|
||||||
|
ORDER BY p.ref ASC,p.label ASC';
|
||||||
|
|
||||||
|
$res = $this->db->query($sql);
|
||||||
|
if($res) {
|
||||||
|
while($obj = $this->db->fetch_object($res)){
|
||||||
|
$this->add_product($obj->fk_product, $obj->fk_entrepot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static function getLink($id) {
|
static function getLink($id) {
|
||||||
global $langs,$db;
|
global $langs,$db;
|
||||||
|
|
||||||
|
|||||||
@ -83,34 +83,7 @@ function _action()
|
|||||||
$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');
|
||||||
|
|
||||||
$e = new Entrepot($db);
|
$inventory->add_products_for($fk_warehouse,$fk_category,$fk_supplier,$only_prods_in_stock);
|
||||||
$e->fetch($fk_warehouse);
|
|
||||||
$TChildWarehouses = array($fk_warehouse);
|
|
||||||
$e->get_children_warehouses($fk_warehouse, $TChildWarehouses);
|
|
||||||
|
|
||||||
$sql = 'SELECT ps.fk_product, ps.fk_entrepot
|
|
||||||
FROM '.MAIN_DB_PREFIX.'product_stock ps
|
|
||||||
INNER JOIN '.MAIN_DB_PREFIX.'product p ON (p.rowid = ps.fk_product)
|
|
||||||
LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product cp ON (cp.fk_product = p.rowid)
|
|
||||||
LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid)
|
|
||||||
WHERE ps.fk_entrepot IN ('.implode(', ', $TChildWarehouses).')';
|
|
||||||
|
|
||||||
if($fk_category>0) $sql.= " AND cp.fk_categorie=".$fk_category;
|
|
||||||
if($fk_supplier>0) $sql.= " AND pfp.fk_soc=".$fk_supplier;
|
|
||||||
if($only_prods_in_stock>0) $sql.= ' AND ps.reel > 0';
|
|
||||||
|
|
||||||
$sql.=' GROUP BY ps.fk_product, ps.fk_entrepot
|
|
||||||
ORDER BY p.ref ASC,p.label ASC';
|
|
||||||
|
|
||||||
|
|
||||||
$res = $db->query($sql);
|
|
||||||
if($res) {
|
|
||||||
while($obj = $db->fetch_object($res)){
|
|
||||||
|
|
||||||
$inventory->add_product($obj->fk_product, $obj->fk_entrepot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$inventory->update($user);
|
$inventory->update($user);
|
||||||
|
|
||||||
header('Location: '.dol_buildpath('inventory/inventory.php?id='.$inventory->id.'&action=edit', 1));
|
header('Location: '.dol_buildpath('inventory/inventory.php?id='.$inventory->id.'&action=edit', 1));
|
||||||
@ -134,14 +107,14 @@ function _action()
|
|||||||
$id = GETPOST('id');
|
$id = GETPOST('id');
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
$inventory = new Inventory($db);
|
||||||
$inventory->load($PDOdb, $id);
|
$inventory->fetch($id);
|
||||||
|
|
||||||
$inventory->set_values($_REQUEST);
|
$inventory->set_values($_REQUEST);
|
||||||
|
|
||||||
if ($inventory->errors)
|
if ($inventory->errors)
|
||||||
{
|
{
|
||||||
setEventMessage($inventory->errors, 'errors');
|
setEventMessage($inventory->errors, 'errors');
|
||||||
_fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'edit');
|
_card( $inventory, 'edit');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -156,18 +129,18 @@ function _action()
|
|||||||
$id = GETPOST('id');
|
$id = GETPOST('id');
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
$inventory = new Inventory($db);
|
||||||
$inventory->load($PDOdb, $id);
|
$inventory->fetch($id);
|
||||||
|
|
||||||
if($inventory->status == 0) {
|
if($inventory->status == 0) {
|
||||||
$inventory->status = 1;
|
$inventory->status = 1;
|
||||||
$inventory->save($PDOdb);
|
$inventory->update($user);
|
||||||
|
|
||||||
_fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'view');
|
_card( $inventory, 'view');
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'view');
|
_card( $inventory, 'view');
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -181,7 +154,7 @@ function _action()
|
|||||||
|
|
||||||
$inventory->changePMP($PDOdb);
|
$inventory->changePMP($PDOdb);
|
||||||
|
|
||||||
_fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'view');
|
_card( $inventory, 'view');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -235,7 +208,7 @@ function _action()
|
|||||||
$inventory->sort_det();
|
$inventory->sort_det();
|
||||||
}
|
}
|
||||||
|
|
||||||
_fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'edit');
|
_card( $inventory, 'edit');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -261,16 +234,16 @@ function _action()
|
|||||||
if (!$user->rights->inventory->create) accessforbidden();
|
if (!$user->rights->inventory->create) accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
$id = __get('id', 0, 'int');
|
$id = GETPOST('id');
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
$inventory = new Inventory($db);
|
||||||
$inventory->load($PDOdb, $id);
|
$inventory->fetch($id);
|
||||||
|
|
||||||
$inventory->deleteAllLine($PDOdb);
|
$inventory->deleteAllLine($PDOdb);
|
||||||
|
|
||||||
setEventMessage('Inventaire vidé');
|
setEventMessage('Inventaire vidé');
|
||||||
|
|
||||||
_fiche($PDOdb, $user, $db, $conf, $langs, $inventory, 'edit');
|
_card( $inventory, 'edit');
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -278,33 +251,23 @@ function _action()
|
|||||||
if (!$user->rights->inventory->create) accessforbidden();
|
if (!$user->rights->inventory->create) accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
$id = __get('id', 0, 'int');
|
$id = GETPOST('id');
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
$inventory = new Inventory($db);
|
||||||
$inventory->load($PDOdb, $id);
|
$inventory->fetch($id);
|
||||||
|
|
||||||
$inventory->delete($PDOdb);
|
$inventory->delete($user);
|
||||||
|
|
||||||
header('Location: '.dol_buildpath('/inventory/inventory.php', 1));
|
header('Location: '.dol_buildpath('/inventory/inventory.php', 1));
|
||||||
exit;
|
exit;
|
||||||
//_list();
|
//_list();
|
||||||
|
|
||||||
case 'printDoc':
|
|
||||||
|
|
||||||
$id = __get('id', 0, 'int');
|
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
|
||||||
$inventory->load($PDOdb, $id);
|
|
||||||
|
|
||||||
generateODT($PDOdb, $db, $conf, $langs, $inventory);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'exportCSV':
|
case 'exportCSV':
|
||||||
|
|
||||||
$id = __get('id', 0, 'int');
|
$id = GETPOST('id');
|
||||||
|
|
||||||
$inventory = new Inventory($db);
|
$inventory = new Inventory($db);
|
||||||
$inventory->load($PDOdb, $id);
|
$inventory->fetch($id);
|
||||||
|
|
||||||
exportCSV($inventory);
|
exportCSV($inventory);
|
||||||
|
|
||||||
@ -453,7 +416,7 @@ function _card(&$inventory, $mode='edit')
|
|||||||
$warehouse = new Entrepot($db);
|
$warehouse = new Entrepot($db);
|
||||||
$warehouse->fetch($inventory->fk_warehouse);
|
$warehouse->fetch($inventory->fk_warehouse);
|
||||||
|
|
||||||
print dol_get_fiche_head(inventoryPrepareHead($inventory, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), '&action='.$mode));
|
print dol_get_fiche_head(inventoryPrepareHead($inventory, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), empty($mode) ? '': '&action='.$mode));
|
||||||
|
|
||||||
$lines = array();
|
$lines = array();
|
||||||
_card_line($inventory, $lines, $mode);
|
_card_line($inventory, $lines, $mode);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user