2
0
forked from Wavyzz/dolibarr

Refactoring and fix

This commit is contained in:
atm-ph
2017-03-25 18:13:39 +01:00
parent e3afa06cf3
commit fce8e08b51
6 changed files with 83 additions and 87 deletions

View File

@@ -517,7 +517,7 @@ class CoreObject extends CommonObject
$this->db->begin();
$query = $this->set_save_query();
$query['datec'] = date("Y-m-d H:i:s", $this->datec);
$query['datec'] = date("Y-m-d H:i:s", dol_now());
$res = $this->db->insert($this->table_element, $query);
if($res)

View File

@@ -19,21 +19,19 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class Listview {
function __construct(&$db, $id ) {
class Listview
{
function __construct(&$db, $id)
{
$this->db = &$db;
$this->id = $id;
$this->TTotalTmp=array();
$this->sql = '';
}
private function init(&$TParam) {
private function init(&$TParam)
{
global $conf, $langs;
if(!isset($TParam['hide']))$TParam['hide']=array();
@@ -574,7 +572,7 @@ class Listview {
$this->init($TParam);
$this->parse_array($THeader, $TField, $TParam,$TField);
$this->parse_array($THeader, $TField, $TParam);
list($TTotal, $TTotalGroup)=$this->get_total($TField, $TParam);
$this->renderList($THeader, $TField,$TTotal,$TTotalGroup, $TParam);
@@ -610,13 +608,14 @@ class Listview {
return $sql;
}
private function parse_array(&$THeader, &$TField, &$TParam, $TField) {
$first=true;
private function parse_array(&$THeader, &$TField, &$TParam)
{
$first = true;
$this->THideFlip = array_flip($TParam['hide']);
$this->TTotalTmp=array();
if(empty($TField)) return false;
if (empty($TField)) return false;
foreach($TField as $row) {
if($first) {
@@ -844,7 +843,7 @@ class Listview {
$this->TTotalTmp=array();
$this->THideFlip = array_flip($TParam['hide']);
var_dump($this->sql);
$res = $this->db->query($this->sql);
if($res!==false) {

View File

@@ -6,20 +6,23 @@
$get = GETPOST('get');
$put = GETPOST('put');
switch ($put) {
switch ($put)
{
case 'qty':
if (!$user->rights->inventory->write) { echo -1; exit; }
if (empty($user->rights->inventory->write)) { echo -1; exit; }
$fk_det_inventory = GETPOST('fk_det_inventory');
$det = new Inventorydet($db);
if( $det->fetch( $fk_det_inventory)) {
if( $det->fetch( $fk_det_inventory))
{
$det->qty_view+=GETPOST('qty');
$det->update($user);
echo $det->qty_view;
}
else {
else
{
echo -2;
}
@@ -31,17 +34,18 @@
$fk_det_inventory = GETPOST('fk_det_inventory');
$det = new Inventorydet($db);
if( $det->fetch( $fk_det_inventory)) {
if( $det->fetch( $fk_det_inventory))
{
$det->new_pmp=price2num(GETPOST('pmp'));
$det->update($user);
echo $det->new_pmp;
}
else {
else
{
echo -2;
}
break;
}

View File

@@ -574,9 +574,10 @@ class Inventorydet extends CoreObject
* Get object and children from database
*
* @param int $id id of inventorydet object
* @param bool $loadChild load children
* @return int
*/
function fetch($id)
function fetch($id, $loadChild = true)
{
$res = parent::fetch($id);
$this->load_product();

View File

@@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$langs->load("stock");
$langs->load("inventory");
if(!$user->rights->inventory->read) accessforbidden();
if(empty($user->rights->inventory->read)) accessforbidden();
_action();
@@ -54,7 +54,7 @@ function _action()
switch($action) {
case 'create':
if (!$user->rights->inventory->create) accessforbidden();
if (empty($user->rights->inventory->create)) accessforbidden();
$inventory = new Inventory($db);
@@ -63,7 +63,7 @@ function _action()
break;
case 'confirmCreate':
if (!$user->rights->inventory->create) accessforbidden();
if (empty($user->rights->inventory->create)) accessforbidden();
$inventory = new Inventory($db);
$inventory->set_values($_POST);

View File

@@ -36,26 +36,18 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$langs->load("stock");
$langs->load("inventory");
if(!$user->rights->inventory->read) accessforbidden();
if (empty($user->rights->inventory->read)) accessforbidden();
_list();
llxHeader('',$langs->trans('inventoryListTitle'),'','');
echo '<form name="formListInvetory" action="'.$_SERVER['PHP_SELF'].'" method="post" >';
function _list()
{
$inventory = new Inventory($db);
$list = new ListView($db,'listInventory');
global $db, $conf, $langs, $user;
$THide = array('label','title');
llxHeader('',$langs->trans('inventoryListTitle'),'','');
echo '<form name="formListInvetory" action="'.$_SERVER['PHP_SELF'].'" method="post" >';
$inventory = new Inventory($db);
$l = new ListView($db,'listInventory');
$THide = array('label','title');
echo $l->render(Inventory::getSQL('All'), array(
echo $list->render(Inventory::getSQL('All'), array(
'link'=>array(
'fk_warehouse'=>'<a href="'.DOL_URL_ROOT.'/product/stock/card.php?id=@val@">'.img_picto('','object_stock.png','',0).' @label@</a>'
)
@@ -86,17 +78,17 @@ function _list()
'date_inventory'=>'calendars'
,'status'=>array(1=>$langs->trans("inventoryValidate"), 0=>$langs->trans("inventoryDraft"))
)
));
));
if ($user->rights->inventory->create)
{
if (!empty($user->rights->inventory->create))
{
print '<div class="tabsAction">';
print '<a class="butAction" href="inventory.php?action=create">'.$langs->trans('inventoryCreate').'</a>';
print '</div>';
}
echo '</form>';
llxFooter('');
}
echo '</form>';
llxFooter('');
$db->close();