diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index ec6442c2302..6454c6e814b 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -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) diff --git a/htdocs/core/class/listview.class.php b/htdocs/core/class/listview.class.php index 46a766a1206..c0579a47850 100644 --- a/htdocs/core/class/listview.class.php +++ b/htdocs/core/class/listview.class.php @@ -19,21 +19,19 @@ along with this program. If not, see . */ -class Listview { +class Listview +{ - function __construct(&$db, $id ) { - + 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; - - $this->THideFlip = array_flip($TParam['hide']); + 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) { diff --git a/htdocs/inventory/ajax/ajax.inventory.php b/htdocs/inventory/ajax/ajax.inventory.php index f2f5ef54903..c1f372806c8 100644 --- a/htdocs/inventory/ajax/ajax.inventory.php +++ b/htdocs/inventory/ajax/ajax.inventory.php @@ -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; - } diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php index 05996d02489..46f27906cc9 100644 --- a/htdocs/inventory/class/inventory.class.php +++ b/htdocs/inventory/class/inventory.class.php @@ -573,10 +573,11 @@ class Inventorydet extends CoreObject /** * Get object and children from database * - * @param int $id id of inventorydet object + * @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(); diff --git a/htdocs/inventory/inventory.php b/htdocs/inventory/inventory.php index 7e43c3ce44e..403b148ec2c 100644 --- a/htdocs/inventory/inventory.php +++ b/htdocs/inventory/inventory.php @@ -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); diff --git a/htdocs/inventory/list.php b/htdocs/inventory/list.php index c6846cfc618..2fb1a2b7f31 100644 --- a/htdocs/inventory/list.php +++ b/htdocs/inventory/list.php @@ -36,67 +36,59 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $langs->load("stock"); $langs->load("inventory"); -if(!$user->rights->inventory->read) accessforbidden(); - -_list(); - - -function _list() -{ - - global $db, $conf, $langs, $user; +if (empty($user->rights->inventory->read)) accessforbidden(); - llxHeader('',$langs->trans('inventoryListTitle'),'',''); - - echo '
'; - - $inventory = new Inventory($db); - $l = new ListView($db,'listInventory'); +llxHeader('',$langs->trans('inventoryListTitle'),'',''); - $THide = array('label','title'); +echo ''; - echo $l->render(Inventory::getSQL('All'), array( - 'link'=>array( - 'fk_warehouse'=>''.img_picto('','object_stock.png','',0).' @label@' - ) - ,'translate'=>array() - ,'hide'=>$THide - ,'type'=>array( - 'datec'=>'date' - ,'tms'=>'datetime' - ,'date_inventory'=>'date' - ) - ,'list'=>array( - 'title'=>$langs->trans('inventoryListTitle') - ,'messageNothing'=>$langs->trans('inventoryListEmpty') - ) - ,'title'=>array( - 'rowid'=>$langs->trans('Title') - ,'fk_warehouse'=>$langs->trans('Warehouse') - ,'date_inventory'=>$langs->trans('InventoryDate') - ,'datec'=>$langs->trans('DateCreation') - ,'tms'=>$langs->trans('DateUpdate') - ,'status'=>$langs->trans('Status') - ) - ,'eval'=>array( - 'status' => '(@val@ ? img_picto("'.$langs->trans("inventoryValidate").'", "statut4") : img_picto("'.$langs->trans("inventoryDraft").'", "statut3"))' - ,'rowid'=>'Inventory::getLink(@val@)' - ) - ,'search'=>array( - 'date_inventory'=>'calendars' - ,'status'=>array(1=>$langs->trans("inventoryValidate"), 0=>$langs->trans("inventoryDraft")) - ) - )); +$inventory = new Inventory($db); +$list = new ListView($db,'listInventory'); + +$THide = array('label','title'); + +echo $list->render(Inventory::getSQL('All'), array( + 'link'=>array( + 'fk_warehouse'=>''.img_picto('','object_stock.png','',0).' @label@' + ) + ,'translate'=>array() + ,'hide'=>$THide + ,'type'=>array( + 'datec'=>'date' + ,'tms'=>'datetime' + ,'date_inventory'=>'date' + ) + ,'list'=>array( + 'title'=>$langs->trans('inventoryListTitle') + ,'messageNothing'=>$langs->trans('inventoryListEmpty') + ) + ,'title'=>array( + 'rowid'=>$langs->trans('Title') + ,'fk_warehouse'=>$langs->trans('Warehouse') + ,'date_inventory'=>$langs->trans('InventoryDate') + ,'datec'=>$langs->trans('DateCreation') + ,'tms'=>$langs->trans('DateUpdate') + ,'status'=>$langs->trans('Status') + ) + ,'eval'=>array( + 'status' => '(@val@ ? img_picto("'.$langs->trans("inventoryValidate").'", "statut4") : img_picto("'.$langs->trans("inventoryDraft").'", "statut3"))' + ,'rowid'=>'Inventory::getLink(@val@)' + ) + ,'search'=>array( + 'date_inventory'=>'calendars' + ,'status'=>array(1=>$langs->trans("inventoryValidate"), 0=>$langs->trans("inventoryDraft")) + ) +)); - if ($user->rights->inventory->create) - { - print '
'; - print ''.$langs->trans('inventoryCreate').''; - print '
'; - } +if (!empty($user->rights->inventory->create)) +{ + print '
'; + print ''.$langs->trans('inventoryCreate').''; + print '
'; +} - echo '
'; - - llxFooter(''); -} \ No newline at end of file +echo ''; + +llxFooter(''); +$db->close(); \ No newline at end of file