mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 17:18:13 +01:00
@@ -1,152 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
|
||||||
* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
|
|
||||||
*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file admin/inventory.php
|
|
||||||
* \ingroup inventory
|
|
||||||
* \brief This file is an example module setup page
|
|
||||||
* Put some comments here
|
|
||||||
*/
|
|
||||||
// Dolibarr environment
|
|
||||||
require '../main.inc.php';
|
|
||||||
|
|
||||||
|
|
||||||
// Libraries
|
|
||||||
require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
|
|
||||||
require_once DOL_DOCUMENT_ROOT .'/inventory/lib/inventory.lib.php';
|
|
||||||
|
|
||||||
// Translations
|
|
||||||
$langs->load("stock");
|
|
||||||
$langs->load("inventory");
|
|
||||||
|
|
||||||
// Access control
|
|
||||||
if (! $user->admin) {
|
|
||||||
accessforbidden();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parameters
|
|
||||||
$action = GETPOST('action', 'alpha');
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Actions
|
|
||||||
*/
|
|
||||||
if (preg_match('/set_(.*)/',$action,$reg))
|
|
||||||
{
|
|
||||||
$code=$reg[1];
|
|
||||||
if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0)
|
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preg_match('/del_(.*)/',$action,$reg))
|
|
||||||
{
|
|
||||||
$code=$reg[1];
|
|
||||||
if (dolibarr_del_const($db, $code, 0) > 0)
|
|
||||||
{
|
|
||||||
Header("Location: ".$_SERVER["PHP_SELF"]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* View
|
|
||||||
*/
|
|
||||||
$page_name = "inventorySetup";
|
|
||||||
llxHeader('', $langs->trans($page_name));
|
|
||||||
|
|
||||||
// Subheader
|
|
||||||
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">'
|
|
||||||
. $langs->trans("BackToModuleList") . '</a>';
|
|
||||||
print_fiche_titre($langs->trans($page_name), $linkback);
|
|
||||||
|
|
||||||
// Configuration header
|
|
||||||
$head = inventoryAdminPrepareHead();
|
|
||||||
dol_fiche_head(
|
|
||||||
$head,
|
|
||||||
'settings',
|
|
||||||
$langs->trans("Module104420Name"),
|
|
||||||
0,
|
|
||||||
"inventory@inventory"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Setup page goes here
|
|
||||||
$form=new Form($db);
|
|
||||||
$var=false;
|
|
||||||
print '<table class="noborder" width="100%">';
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td>'.$langs->trans("Parameters").'</td>'."\n";
|
|
||||||
print '<td align="center" width="20"> </td>';
|
|
||||||
print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
|
|
||||||
|
|
||||||
// Example with a yes / no select
|
|
||||||
$var=!$var;
|
|
||||||
print '<tr '.$bc[$var].'>';
|
|
||||||
print '<td>'.$langs->trans("INVENTORY_DISABLE_VIRTUAL").'</td>';
|
|
||||||
print '<td align="center" width="20"> </td>';
|
|
||||||
print '<td align="right" width="300">';
|
|
||||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
||||||
print '<input type="hidden" name="action" value="set_INVENTORY_DISABLE_VIRTUAL">';
|
|
||||||
print $form->selectyesno("INVENTORY_DISABLE_VIRTUAL",$conf->global->INVENTORY_DISABLE_VIRTUAL,1);
|
|
||||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
|
||||||
print '</form>';
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Example with a yes / no select
|
|
||||||
$var=!$var;
|
|
||||||
print '<tr '.$bc[$var].'>';
|
|
||||||
print '<td>'.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").'</td>';
|
|
||||||
print '<td align="center" width="20"> </td>';
|
|
||||||
print '<td align="right" width="300">';
|
|
||||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
||||||
print '<input type="hidden" name="action" value="set_INVENTORY_USE_MIN_PA_IF_NO_LAST_PA">';
|
|
||||||
print $form->selectyesno("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA",$conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA,1);
|
|
||||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
|
||||||
print '</form>';
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Example with a yes / no select
|
|
||||||
$var=!$var;
|
|
||||||
print '<tr '.$bc[$var].'>';
|
|
||||||
print '<td>'.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").'</td>';
|
|
||||||
print '<td align="center" width="20"> </td>';
|
|
||||||
print '<td align="right" width="300">';
|
|
||||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
||||||
print '<input type="hidden" name="action" value="set_INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT">';
|
|
||||||
print $form->selectyesno("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT",$conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT,1);
|
|
||||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
|
||||||
print '</form>';
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
|
|
||||||
llxFooter();
|
|
||||||
|
|
||||||
$db->close();
|
|
||||||
@@ -432,6 +432,61 @@ if ($virtualdiffersfromphysical)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
print '<br />';
|
||||||
|
if ($conf->global->MAIN_LEVEL_FEATURES >= 2)
|
||||||
|
{
|
||||||
|
$var=false;
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td>'.$langs->trans("Inventory").'</td>'."\n";
|
||||||
|
print '<td align="center" width="20"> </td>';
|
||||||
|
print '<td align="center" width="100"> </td>'."\n";
|
||||||
|
|
||||||
|
// Example with a yes / no select
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td>'.$langs->trans("INVENTORY_DISABLE_VIRTUAL").'</td>';
|
||||||
|
print '<td align="center" width="20"> </td>';
|
||||||
|
print '<td align="right" width="300">';
|
||||||
|
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="action" value="set_INVENTORY_DISABLE_VIRTUAL">';
|
||||||
|
print $form->selectyesno("INVENTORY_DISABLE_VIRTUAL",$conf->global->INVENTORY_DISABLE_VIRTUAL,1);
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||||
|
print '</form>';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Example with a yes / no select
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td>'.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").'</td>';
|
||||||
|
print '<td align="center" width="20"> </td>';
|
||||||
|
print '<td align="right" width="300">';
|
||||||
|
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="action" value="set_INVENTORY_USE_MIN_PA_IF_NO_LAST_PA">';
|
||||||
|
print $form->selectyesno("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA",$conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA,1);
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||||
|
print '</form>';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Example with a yes / no select
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td>'.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").'</td>';
|
||||||
|
print '<td align="center" width="20"> </td>';
|
||||||
|
print '<td align="right" width="300">';
|
||||||
|
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="action" value="set_INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT">';
|
||||||
|
print $form->selectyesno("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT",$conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT,1);
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||||
|
print '</form>';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
}
|
||||||
|
|
||||||
$var=true;
|
$var=true;
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
|
|
||||||
@@ -508,6 +563,7 @@ if ($conf->global->PRODUIT_SOUSPRODUITS)
|
|||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||||
* Copyright (C) 2016 Bahfir abbes <dolipar@dolipar.org>
|
* Copyright (C) 2016 Bahfir abbes <dolipar@dolipar.org>
|
||||||
|
* Copyright (C) 2017 ATM Consulting <support@atm-consulting.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -4662,7 +4663,159 @@ abstract class CommonObject
|
|||||||
return $buyPrice;
|
return $buyPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function test if type is date
|
||||||
|
*
|
||||||
|
* @param array $info content informations of field
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isDate($info)
|
||||||
|
{
|
||||||
|
if(isset($info['type']) && $info['type']=='date') return true;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function test if type is array
|
||||||
|
*
|
||||||
|
* @param array $info content informations of field
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isArray($info)
|
||||||
|
{
|
||||||
|
if(is_array($info))
|
||||||
|
{
|
||||||
|
if(isset($info['type']) && $info['type']=='array') return true;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function test if type is null
|
||||||
|
*
|
||||||
|
* @param array $info content informations of field
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isNull($info)
|
||||||
|
{
|
||||||
|
if(is_array($info))
|
||||||
|
{
|
||||||
|
if(isset($info['type']) && $info['type']=='null') return true;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function test if type is integer
|
||||||
|
*
|
||||||
|
* @param array $info content informations of field
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isInt($info)
|
||||||
|
{
|
||||||
|
if(is_array($info))
|
||||||
|
{
|
||||||
|
if(isset($info['type']) && ($info['type']=='int' || $info['type']=='integer' )) return true;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function test if type is float
|
||||||
|
*
|
||||||
|
* @param array $info content informations of field
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isFloat($info)
|
||||||
|
{
|
||||||
|
if(is_array($info))
|
||||||
|
{
|
||||||
|
if(isset($info['type']) && $info['type']=='float') return true;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function test if type is text
|
||||||
|
*
|
||||||
|
* @param array $info content informations of field
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isText($info)
|
||||||
|
{
|
||||||
|
if(is_array($info))
|
||||||
|
{
|
||||||
|
if(isset($info['type']) && $info['type']=='text') return true;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function test if is indexed
|
||||||
|
*
|
||||||
|
* @param array $info content informations of field
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isIndex($info)
|
||||||
|
{
|
||||||
|
if(is_array($info))
|
||||||
|
{
|
||||||
|
if(isset($info['index']) && $info['index']==true) return true;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to prepare the values to insert
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function set_save_query()
|
||||||
|
{
|
||||||
|
$query=array();
|
||||||
|
foreach ($this->fields as $field=>$info)
|
||||||
|
{
|
||||||
|
if($this->isDate($info))
|
||||||
|
{
|
||||||
|
if(empty($this->{$field}))
|
||||||
|
{
|
||||||
|
$query[$field] = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query[$field] = $this->db->idate($this->{$field});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if($this->isArray($info))
|
||||||
|
{
|
||||||
|
$query[$field] = serialize($this->{$field});
|
||||||
|
}
|
||||||
|
else if($this->isInt($info))
|
||||||
|
{
|
||||||
|
$query[$field] = (int) price2num($this->{$field});
|
||||||
|
}
|
||||||
|
else if($this->isFloat($info))
|
||||||
|
{
|
||||||
|
$query[$field] = (double) price2num($this->{$field});
|
||||||
|
}
|
||||||
|
elseif($this->isNull($info))
|
||||||
|
{
|
||||||
|
$query[$field] = (is_null($this->{$field}) || (empty($this->{$field}) && $this->{$field}!==0 && $this->{$field}!=='0') ? null : $this->{$field});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query[$field] = $this->{$field};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create object into database
|
* Create object into database
|
||||||
@@ -4674,28 +4827,82 @@ abstract class CommonObject
|
|||||||
*/
|
*/
|
||||||
public function createCommon(User $user, $notrigger = false)
|
public function createCommon(User $user, $notrigger = false)
|
||||||
{
|
{
|
||||||
foreach ($this->fields as $k => $v) {
|
|
||||||
|
|
||||||
$keys[] = $k;
|
$fields = array_merge(array('datec'=>$this->db->idate(dol_now())), $this->set_save_query());
|
||||||
$values[] = $this->quote($v);
|
|
||||||
|
foreach ($fields as $k => $v) {
|
||||||
|
|
||||||
|
$keys[] = $k;
|
||||||
|
$values[] = $this->quote($v);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'
|
||||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$table.'
|
|
||||||
( '.implode( ",", $keys ).' )
|
( '.implode( ",", $keys ).' )
|
||||||
VALUES ( '.implode( ",", $values ).' ) ';
|
VALUES ( '.implode( ",", $values ).' ) ';
|
||||||
|
$res = $this->db->query( $sql );
|
||||||
$res = $this->query($sql);
|
|
||||||
if($res===false) {
|
if($res===false) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Add triggers
|
// TODO Add triggers
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to load data into current object this
|
||||||
|
*
|
||||||
|
* @param stdClass $obj Contain data of object from database
|
||||||
|
*/
|
||||||
|
private function set_vars_by_db(&$obj)
|
||||||
|
{
|
||||||
|
foreach ($this->fields as $field => $info)
|
||||||
|
{
|
||||||
|
if($this->isDate($info))
|
||||||
|
{
|
||||||
|
if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0;
|
||||||
|
else $this->{$field} = strtotime($obj->{$field});
|
||||||
|
}
|
||||||
|
elseif($this->isArray($info))
|
||||||
|
{
|
||||||
|
$this->{$field} = @unserialize($obj->{$field});
|
||||||
|
// Hack for data not in UTF8
|
||||||
|
if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field}));
|
||||||
|
}
|
||||||
|
elseif($this->isInt($info))
|
||||||
|
{
|
||||||
|
$this->{$field} = (int) $obj->{$field};
|
||||||
|
}
|
||||||
|
elseif($this->isFloat($info))
|
||||||
|
{
|
||||||
|
$this->{$field} = (double) $obj->{$field};
|
||||||
|
}
|
||||||
|
elseif($this->isNull($info))
|
||||||
|
{
|
||||||
|
$val = $obj->{$field};
|
||||||
|
// zero is not null
|
||||||
|
$this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->{$field} = $obj->{$field};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to concat keys of fields
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function get_field_list()
|
||||||
|
{
|
||||||
|
$keys = array_keys($this->fields);
|
||||||
|
return implode(',', $keys);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load object in memory from the database
|
* Load object in memory from the database
|
||||||
@@ -4708,6 +4915,32 @@ abstract class CommonObject
|
|||||||
public function fetchCommon($id, $ref = null)
|
public function fetchCommon($id, $ref = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (empty($id) && empty($ref)) return false;
|
||||||
|
|
||||||
|
$sql = 'SELECT '.$this->get_field_list().', datec, tms';
|
||||||
|
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
|
||||||
|
|
||||||
|
if(!empty($id)) $sql.= ' WHERE rowid = '.$id;
|
||||||
|
else $sql.= ' WHERE ref = \''.$this->quote($ref).'\'';
|
||||||
|
|
||||||
|
$res = $this->db->query($sql);
|
||||||
|
if($obj = $this->db->fetch_object($res))
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
$this->set_vars_by_db($obj);
|
||||||
|
|
||||||
|
$this->datec = $this->db->idate($obj->datec);
|
||||||
|
$this->tms = $this->db->idate($obj->tms);
|
||||||
|
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error = $this->db->lasterror();
|
||||||
|
$this->errors[] = $this->error;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4720,34 +4953,36 @@ abstract class CommonObject
|
|||||||
*/
|
*/
|
||||||
public function updateCommon(User $user, $notrigger = false)
|
public function updateCommon(User $user, $notrigger = false)
|
||||||
{
|
{
|
||||||
foreach ($this->fields as $k => $v) {
|
$fields = $this->set_save_query();
|
||||||
|
|
||||||
if (is_array($key)){
|
foreach ($fields as $k => $v) {
|
||||||
$i=array_search($k, $key);
|
|
||||||
if ( $i !== false) {
|
if (is_array($key)){
|
||||||
$where[] = $key[$i].'=' . $this->quote( $v ) ;
|
$i=array_search($k, $key);
|
||||||
continue;
|
if ( $i !== false) {
|
||||||
}
|
$where[] = $key[$i].'=' . $this->quote( $v ) ;
|
||||||
} else {
|
continue;
|
||||||
if ( $k == $key) {
|
}
|
||||||
$where[] = $k.'=' .$this->quote( $v ) ;
|
} else {
|
||||||
continue;
|
if ( $k == $key) {
|
||||||
}
|
$where[] = $k.'=' .$this->quote( $v ) ;
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
$tmp[] = $k.'='.$this->quote($v);
|
}
|
||||||
}
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET '.implode( ',', $tmp ).' WHERE ' . implode(' AND ',$where) ;
|
$tmp[] = $k.'='.$this->quote($v);
|
||||||
$res = $this->query( $sql );
|
}
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode( ',', $tmp ).' WHERE rowid='.$this->id ;
|
||||||
if($res===false) {
|
$res = $this->db->query( $sql );
|
||||||
//error
|
|
||||||
return false;
|
if($res===false) {
|
||||||
}
|
//error
|
||||||
|
return false;
|
||||||
// TODO Add triggers
|
}
|
||||||
|
|
||||||
return true;
|
// TODO Add triggers
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4760,7 +4995,16 @@ abstract class CommonObject
|
|||||||
*/
|
*/
|
||||||
public function deleteCommon(User $user, $notrigger = false)
|
public function deleteCommon(User $user, $notrigger = false)
|
||||||
{
|
{
|
||||||
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id;
|
||||||
|
|
||||||
|
$res = $this->db->query( $sql );
|
||||||
|
if($res===false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Add triggers
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4769,11 +5013,11 @@ abstract class CommonObject
|
|||||||
* @param string|int $value value to protect
|
* @param string|int $value value to protect
|
||||||
* @return string|int
|
* @return string|int
|
||||||
*/
|
*/
|
||||||
function quote($value) {
|
protected function quote($value) {
|
||||||
|
|
||||||
if(is_null($value)) return 'NULL';
|
if(is_null($value)) return 'NULL';
|
||||||
else if(is_numeric($value)) return $value;
|
else if(is_numeric($value)) return $value;
|
||||||
else return "'".$this->escape( $value )."'";
|
else return "'".$this->db->escape( $value )."'";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,10 +59,10 @@ class CoreObject extends CommonObject
|
|||||||
{
|
{
|
||||||
foreach ($this->fields as $field=>$info)
|
foreach ($this->fields as $field=>$info)
|
||||||
{
|
{
|
||||||
if ($this->is_date($info)) $this->{$field} = time();
|
if ($this->isDate($info)) $this->{$field} = time();
|
||||||
elseif ($this->is_array($info)) $this->{$field} = array();
|
elseif ($this->isArray($info)) $this->{$field} = array();
|
||||||
elseif ($this->is_int($info)) $this->{$field} = (int) 0;
|
elseif ($this->isInt($info)) $this->{$field} = (int) 0;
|
||||||
elseif ($this->is_float($info)) $this->{$field} = (double) 0;
|
elseif ($this->isFloat($info)) $this->{$field} = (double) 0;
|
||||||
else $this->{$field} = '';
|
else $this->{$field} = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,216 +97,6 @@ class CoreObject extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Function test if type is date
|
|
||||||
*
|
|
||||||
* @param array $info content informations of field
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function is_date($info)
|
|
||||||
{
|
|
||||||
if(isset($info['type']) && $info['type']=='date') return true;
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function test if type is array
|
|
||||||
*
|
|
||||||
* @param array $info content informations of field
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function is_array($info)
|
|
||||||
{
|
|
||||||
if(is_array($info))
|
|
||||||
{
|
|
||||||
if(isset($info['type']) && $info['type']=='array') return true;
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function test if type is null
|
|
||||||
*
|
|
||||||
* @param array $info content informations of field
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function is_null($info)
|
|
||||||
{
|
|
||||||
if(is_array($info))
|
|
||||||
{
|
|
||||||
if(isset($info['type']) && $info['type']=='null') return true;
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function test if type is integer
|
|
||||||
*
|
|
||||||
* @param array $info content informations of field
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function is_int($info)
|
|
||||||
{
|
|
||||||
if(is_array($info))
|
|
||||||
{
|
|
||||||
if(isset($info['type']) && ($info['type']=='int' || $info['type']=='integer' )) return true;
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function test if type is float
|
|
||||||
*
|
|
||||||
* @param array $info content informations of field
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function is_float($info)
|
|
||||||
{
|
|
||||||
if(is_array($info))
|
|
||||||
{
|
|
||||||
if(isset($info['type']) && $info['type']=='float') return true;
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function test if type is text
|
|
||||||
*
|
|
||||||
* @param array $info content informations of field
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function is_text($info)
|
|
||||||
{
|
|
||||||
if(is_array($info))
|
|
||||||
{
|
|
||||||
if(isset($info['type']) && $info['type']=='text') return true;
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function test if is indexed
|
|
||||||
*
|
|
||||||
* @param array $info content informations of field
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function is_index($info)
|
|
||||||
{
|
|
||||||
if(is_array($info))
|
|
||||||
{
|
|
||||||
if(isset($info['index']) && $info['index']==true) return true;
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to prepare the values to insert
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function set_save_query()
|
|
||||||
{
|
|
||||||
$query=array();
|
|
||||||
foreach ($this->fields as $field=>$info)
|
|
||||||
{
|
|
||||||
if($this->is_date($info))
|
|
||||||
{
|
|
||||||
if(empty($this->{$field}))
|
|
||||||
{
|
|
||||||
$query[$field] = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$query[$field] = $this->db->idate($this->{$field});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if($this->is_array($info))
|
|
||||||
{
|
|
||||||
$query[$field] = serialize($this->{$field});
|
|
||||||
}
|
|
||||||
else if($this->is_int($info))
|
|
||||||
{
|
|
||||||
$query[$field] = (int) price2num($this->{$field});
|
|
||||||
}
|
|
||||||
else if($this->is_float($info))
|
|
||||||
{
|
|
||||||
$query[$field] = (double) price2num($this->{$field});
|
|
||||||
}
|
|
||||||
elseif($this->is_null($info))
|
|
||||||
{
|
|
||||||
$query[$field] = (is_null($this->{$field}) || (empty($this->{$field}) && $this->{$field}!==0 && $this->{$field}!=='0') ? null : $this->{$field});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$query[$field] = $this->{$field};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to concat keys of fields
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function get_field_list()
|
|
||||||
{
|
|
||||||
$keys = array_keys($this->fields);
|
|
||||||
return implode(',', $keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to load data into current object this
|
|
||||||
*
|
|
||||||
* @param stdClass $obj Contain data of object from database
|
|
||||||
*/
|
|
||||||
private function set_vars_by_db(&$obj)
|
|
||||||
{
|
|
||||||
foreach ($this->fields as $field => $info)
|
|
||||||
{
|
|
||||||
if($this->is_date($info))
|
|
||||||
{
|
|
||||||
if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0;
|
|
||||||
else $this->{$field} = strtotime($obj->{$field});
|
|
||||||
}
|
|
||||||
elseif($this->is_array($info))
|
|
||||||
{
|
|
||||||
$this->{$field} = @unserialize($obj->{$field});
|
|
||||||
// Hack for data not in UTF8
|
|
||||||
if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field}));
|
|
||||||
}
|
|
||||||
elseif($this->is_int($info))
|
|
||||||
{
|
|
||||||
$this->{$field} = (int) $obj->{$field};
|
|
||||||
}
|
|
||||||
elseif($this->is_float($info))
|
|
||||||
{
|
|
||||||
$this->{$field} = (double) $obj->{$field};
|
|
||||||
}
|
|
||||||
elseif($this->is_null($info))
|
|
||||||
{
|
|
||||||
$val = $obj->{$field};
|
|
||||||
// zero is not null
|
|
||||||
$this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->{$field} = $obj->{$field};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get object and children from database
|
* Get object and children from database
|
||||||
*
|
*
|
||||||
@@ -316,31 +106,14 @@ class CoreObject extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function fetch($id, $loadChild = true)
|
public function fetch($id, $loadChild = true)
|
||||||
{
|
{
|
||||||
if (empty($id)) return false;
|
|
||||||
|
|
||||||
$sql = 'SELECT '.$this->get_field_list().', datec, tms';
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
|
|
||||||
$sql.= ' WHERE rowid = '.$id;
|
|
||||||
|
|
||||||
$res = $this->db->query($sql);
|
$res = $this->fetchCommon($id);
|
||||||
if($obj = $this->db->fetch_object($res))
|
if($res>0) {
|
||||||
{
|
if ($loadChild) $this->fetchChild();
|
||||||
$this->id = $id;
|
}
|
||||||
$this->set_vars_by_db($obj);
|
|
||||||
|
return $res;
|
||||||
$this->datec = $this->db->idate($obj->datec);
|
|
||||||
$this->tms = $this->db->idate($obj->tms);
|
|
||||||
|
|
||||||
if ($loadChild) $this->fetchChild();
|
|
||||||
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->error = $this->db->lasterror();
|
|
||||||
$this->errors[] = $this->error;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -473,10 +246,7 @@ class CoreObject extends CommonObject
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$query = $this->set_save_query();
|
$res = $this->updateCommon($user);
|
||||||
$query['rowid'] = $this->id;
|
|
||||||
|
|
||||||
$res = $this->db->update($this->table_element, $query, array('rowid'));
|
|
||||||
if ($res)
|
if ($res)
|
||||||
{
|
{
|
||||||
$result = $this->call_trigger(strtoupper($this->element). '_UPDATE', $user);
|
$result = $this->call_trigger(strtoupper($this->element). '_UPDATE', $user);
|
||||||
@@ -516,10 +286,7 @@ class CoreObject extends CommonObject
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$query = $this->set_save_query();
|
$res = $this->createCommon($user);
|
||||||
$query['datec'] = date("Y-m-d H:i:s", dol_now());
|
|
||||||
|
|
||||||
$res = $this->db->insert($this->table_element, $query);
|
|
||||||
if($res)
|
if($res)
|
||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id($this->table_element);
|
$this->id = $this->db->last_insert_id($this->table_element);
|
||||||
@@ -565,7 +332,7 @@ class CoreObject extends CommonObject
|
|||||||
|
|
||||||
if (!$error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$this->db->delete($this->table_element, array('rowid' => $this->id), array('rowid'));
|
$this->deleteCommon($user);
|
||||||
if($this->withChild && !empty($this->childtables))
|
if($this->withChild && !empty($this->childtables))
|
||||||
{
|
{
|
||||||
foreach($this->childtables as &$childTable)
|
foreach($this->childtables as &$childTable)
|
||||||
@@ -669,5 +436,5 @@ class CoreObject extends CommonObject
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,91 +117,39 @@ class modStock extends DolibarrModules
|
|||||||
$this->rights[4][4] = 'mouvement';
|
$this->rights[4][4] = 'mouvement';
|
||||||
$this->rights[4][5] = 'creer';
|
$this->rights[4][5] = 'creer';
|
||||||
|
|
||||||
/*
|
if ($conf->global->MAIN_LEVEL_FEATURES >= 2) {
|
||||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
|
||||||
$this->rights[$r][1] = 'inventoryReadPermission'; // Permission label
|
|
||||||
$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
|
|
||||||
$this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
|
||||||
$r++;
|
|
||||||
|
|
||||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
$this->rights[5][0] = 1006;
|
||||||
$this->rights[$r][1] = 'inventoryCreatePermission'; // Permission label
|
$this->rights[5][1] = 'inventoryReadPermission'; // Permission label
|
||||||
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
|
$this->rights[5][3] = 0; // Permission by default for new user (0/1)
|
||||||
$this->rights[$r][4] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
$this->rights[5][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||||
$r++;
|
|
||||||
|
|
||||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
$this->rights[6][0] = 1007;
|
||||||
$this->rights[$r][1] = 'inventoryWritePermission'; // Permission label
|
$this->rights[6][1] = 'inventoryCreatePermission'; // Permission label
|
||||||
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
|
$this->rights[6][3] = 0; // Permission by default for new user (0/1)
|
||||||
$this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
$this->rights[6][4] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||||
$r++;
|
|
||||||
|
|
||||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
$this->rights[7][0] = 1008;
|
||||||
$this->rights[$r][1] = 'inventoryValidatePermission'; // Permission label
|
$this->rights[7][1] = 'inventoryWritePermission'; // Permission label
|
||||||
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
|
$this->rights[7][3] = 0; // Permission by default for new user (0/1)
|
||||||
$this->rights[$r][4] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
$this->rights[7][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||||
$r++;
|
|
||||||
|
|
||||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
$this->rights[7][0] = 1009;
|
||||||
$this->rights[$r][1] = 'inventoryChangePMPPermission'; // Permission label
|
$this->rights[7][1] = 'inventoryValidatePermission'; // Permission label
|
||||||
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
|
$this->rights[7][3] = 0; // Permission by default for new user (0/1)
|
||||||
$this->rights[$r][4] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
$this->rights[7][4] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||||
$r++;
|
|
||||||
*/
|
$this->rights[7][0] = 1010;
|
||||||
|
$this->rights[7][1] = 'inventoryChangePMPPermission'; // Permission label
|
||||||
|
$this->rights[7][3] = 0; // Permission by default for new user (0/1)
|
||||||
|
$this->rights[7][4] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Main menu entries
|
// Main menu entries
|
||||||
$this->menu = array(); // List of menus to add
|
$this->menu = array(); // List of menus to add
|
||||||
$r=0;
|
$r=0;
|
||||||
|
|
||||||
/*
|
|
||||||
$this->menu[$r]=array(
|
|
||||||
'fk_menu'=>'fk_mainmenu=products', // Put 0 if this is a top menu
|
|
||||||
'type'=>'left', // This is a Top menu entry
|
|
||||||
'titre'=>'Inventory',
|
|
||||||
'mainmenu'=>'products',
|
|
||||||
'leftmenu'=>'inventory_left',
|
|
||||||
'url'=>'/inventory/list.php',
|
|
||||||
'langs'=>'inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
|
||||||
'position'=>100+$r,
|
|
||||||
'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled.
|
|
||||||
'perms'=>'$user->rights->inventory->read', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules
|
|
||||||
'target'=>'',
|
|
||||||
'user'=>2
|
|
||||||
); // 0=Menu for internal users, 1=external users, 2=both
|
|
||||||
$r++;
|
|
||||||
|
|
||||||
$this->menu[$r]=array(
|
|
||||||
'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=inventory_left', // Put 0 if this is a top menu
|
|
||||||
'type'=>'left', // This is a Top menu entry
|
|
||||||
'titre'=>'NewInventory',
|
|
||||||
'mainmenu'=>'products',
|
|
||||||
'leftmenu'=>'inventory_left_create',
|
|
||||||
'url'=>'/inventory/inventory.php?action=create',
|
|
||||||
'position'=>100+$r,
|
|
||||||
'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled.
|
|
||||||
'perms'=>'$user->rights->inventory->create', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules
|
|
||||||
'target'=>'',
|
|
||||||
'user'=>2
|
|
||||||
); // 0=Menu for internal users, 1=external users, 2=both
|
|
||||||
$r++;
|
|
||||||
|
|
||||||
$this->menu[$r]=array(
|
|
||||||
'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=inventory_left', // Put 0 if this is a top menu
|
|
||||||
'type'=>'left', // This is a Top menu entry
|
|
||||||
'titre'=>'ListInventory',
|
|
||||||
'mainmenu'=>'products',
|
|
||||||
'leftmenu'=>'inventory_left_list',
|
|
||||||
'url'=>'/inventory/list.php',
|
|
||||||
'langs'=>'inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
|
||||||
'position'=>100+$r,
|
|
||||||
'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled.
|
|
||||||
'perms'=>'$user->rights->inventory->read', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules
|
|
||||||
'target'=>'',
|
|
||||||
'user'=>2
|
|
||||||
); // 0=Menu for internal users, 1=external users, 2=both
|
|
||||||
$r++;
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Menus
|
// Menus
|
||||||
//-------
|
//-------
|
||||||
$this->menu = 1; // This module add menu entries. They are coded into menu manager.
|
$this->menu = 1; // This module add menu entries. They are coded into menu manager.
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
require '../../../main.inc.php';
|
require '../../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/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');
|
||||||
|
|
||||||
switch ($put)
|
switch ($put)
|
||||||
{
|
{
|
||||||
case 'qty':
|
case 'qty':
|
||||||
if (empty($user->rights->stock->write)) { echo -1; exit; }
|
if (empty($user->rights->stock->creer)) { echo -1; exit; }
|
||||||
|
|
||||||
$fk_det_inventory = GETPOST('fk_det_inventory');
|
$fk_det_inventory = GETPOST('fk_det_inventory');
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
if( $det->fetch( $fk_det_inventory))
|
if( $det->fetch( $fk_det_inventory))
|
||||||
{
|
{
|
||||||
$det->qty_view+=GETPOST('qty');
|
$det->qty_view+=GETPOST('qty');
|
||||||
$det->update($user);
|
$res = $det->update($user);
|
||||||
|
|
||||||
echo $det->qty_view;
|
echo $det->qty_view;
|
||||||
}
|
}
|
||||||
@@ -25,11 +25,11 @@
|
|||||||
{
|
{
|
||||||
echo -2;
|
echo -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'pmp':
|
case 'pmp':
|
||||||
if (!$user->rights->stock->write || !$user->rights->stock->changePMP) { echo -1; exit; }
|
if (empty($user->rights->stock->creer) || empty($user->rights->stock->changePMP)) { echo -1; exit; }
|
||||||
|
|
||||||
$fk_det_inventory = GETPOST('fk_det_inventory');
|
$fk_det_inventory = GETPOST('fk_det_inventory');
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
|||||||
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
|
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
|
||||||
|
|
||||||
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
|
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
|
||||||
$hookmanager->initHooks(array('inventory'));
|
$hookmanager->initHooks(array('inventorycard'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ if (empty($reshook))
|
|||||||
{
|
{
|
||||||
if ($action != 'addlink')
|
if ($action != 'addlink')
|
||||||
{
|
{
|
||||||
$urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1);
|
$urltogo=$backtopage?$backtopage:dol_buildpath('/product/inventory/list.php',1);
|
||||||
header("Location: ".$urltogo);
|
header("Location: ".$urltogo);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
if ($cancel)
|
if ($cancel)
|
||||||
{
|
{
|
||||||
$urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1);
|
$urltogo=$backtopage?$backtopage:dol_buildpath('/product/inventory/list.php',1);
|
||||||
header("Location: ".$urltogo);
|
header("Location: ".$urltogo);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user