2
0
forked from Wavyzz/dolibarr

Fix travis

This commit is contained in:
atm-ph
2017-03-25 23:21:49 +01:00
parent 76b95aeec0
commit 09f645fc9f
5 changed files with 74 additions and 95 deletions

View File

@@ -642,7 +642,7 @@ class CoreObject extends CommonObject
* @param array $Tab Array of values * @param array $Tab Array of values
* @return int * @return int
*/ */
public function set_values(&$Tab) public function setValues(&$Tab)
{ {
foreach ($Tab as $key => $value) foreach ($Tab as $key => $value)
{ {

View File

@@ -90,11 +90,6 @@ function Listview_submitSearch(obj) {
if($form.length>0){ if($form.length>0){
$form.submit(); $form.submit();
} }
else{
//There is no form for search action
null;
}
} }
function Listview_launch_downloadAs(mode,url,token,session_name) { function Listview_launch_downloadAs(mode,url,token,session_name) {
$('#listviewdAS_export_form').remove(); $('#listviewdAS_export_form').remove();
@@ -145,7 +140,7 @@ $(document).ready(function() {
}); });
if(typeof $_GET["get-all-for-export"] != "undefined") { if(typeof $_GET["get-all-for-export"] != "undefined") {
Listview_launch_downloadAs($_GET["mode"],$_GET["url"],$_GET["token"],$_GET["session_name"]); Listview_launch_downloadAs($_GET['mode'],$_GET['url'],$_GET['token'],$_GET['session_name']);
} }
}); });

View File

@@ -93,7 +93,7 @@ class Inventory extends CoreObject
/** /**
* Function to sort children object * Function to sort children object
*/ */
public function sort_det() public function sortDet()
{ {
if(!empty($this->Inventorydet)) usort($this->Inventorydet, array('Inventory', 'customSort')); if(!empty($this->Inventorydet)) usort($this->Inventorydet, array('Inventory', 'customSort'));
} }
@@ -112,7 +112,7 @@ class Inventory extends CoreObject
$res = parent::fetch($id, $loadChild); $res = parent::fetch($id, $loadChild);
if($res > 0) if($res > 0)
{ {
$this->sort_det(); $this->sortDet();
$this->amount = 0; $this->amount = 0;
if(!empty($this->Inventorydet )) if(!empty($this->Inventorydet ))
{ {
@@ -243,7 +243,7 @@ class Inventory extends CoreObject
* @param array $Tab Array of values * @param array $Tab Array of values
* @return int * @return int
*/ */
public function set_values(&$Tab) public function setValues(&$Tab)
{ {
global $langs; global $langs;
@@ -267,7 +267,7 @@ class Inventory extends CoreObject
} }
} }
return parent::set_values($Tab); return parent::setValues($Tab);
} }
/** /**
@@ -296,7 +296,7 @@ class Inventory extends CoreObject
* @param int $fk_warehouse fk_warehouse target * @param int $fk_warehouse fk_warehouse target
* @return bool * @return bool
*/ */
public function add_product($fk_product, $fk_warehouse=0) public function addProduct($fk_product, $fk_warehouse=0)
{ {
$k = $this->addChild('Inventorydet'); $k = $this->addChild('Inventorydet');
$det = &$this->Inventorydet[$k]; $det = &$this->Inventorydet[$k];
@@ -309,7 +309,7 @@ class Inventory extends CoreObject
$date = $this->get_date('date_inventory', 'Y-m-d'); $date = $this->get_date('date_inventory', 'Y-m-d');
if(empty($date)) $date = $this->get_date('datec', 'Y-m-d'); if(empty($date)) $date = $this->get_date('datec', 'Y-m-d');
$det->setStockDate( $date , $fk_warehouse); $det->setStockDate($date, $fk_warehouse);
return true; return true;
} }
@@ -327,7 +327,7 @@ class Inventory extends CoreObject
* @param string $inventorycode Inventory code * @param string $inventorycode Inventory code
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function correct_stock($fk_product, $fk_warehouse, $nbpiece, $movement, $label='', $price=0, $inventorycode='') public function correctStock($fk_product, $fk_warehouse, $nbpiece, $movement, $label='', $price=0, $inventorycode='')
{ {
global $conf, $user; global $conf, $user;
@@ -397,7 +397,7 @@ class Inventory extends CoreObject
//$href = dol_buildpath('/inventory/inventory.php?id='.$this->id.'&action=view', 1); //$href = dol_buildpath('/inventory/inventory.php?id='.$this->id.'&action=view', 1);
$res = $this->correct_stock($product->id, $Inventorydet->fk_warehouse, $nbpiece, $movement, $langs->trans('inventoryMvtStock')); $res = $this->correctStock($product->id, $Inventorydet->fk_warehouse, $nbpiece, $movement, $langs->trans('inventoryMvtStock'));
if ($res < 0) return -1; if ($res < 0) return -1;
} }
} }
@@ -437,14 +437,14 @@ class Inventory extends CoreObject
/** /**
* Function to add products by default from warehouse and children * Function to add products by default from warehouse and children
* *
* @param $fk_warehouse * @param int $fk_warehouse id of warehouse
* @param int $fk_category * @param int $fk_category id of category
* @param int $fk_supplier * @param int $fk_supplier id of supplier
* @param int $only_prods_in_stock * @param int $only_prods_in_stock only product with stock
* *
* @return int * @return int
*/ */
public function add_products_for($fk_warehouse,$fk_category=0,$fk_supplier=0,$only_prods_in_stock=0) public function addProductsFor($fk_warehouse,$fk_category=0,$fk_supplier=0,$only_prods_in_stock=0)
{ {
$warehouse = new Entrepot($this->db); $warehouse = new Entrepot($this->db);
$warehouse->fetch($fk_warehouse); $warehouse->fetch($fk_warehouse);
@@ -469,7 +469,7 @@ class Inventory extends CoreObject
{ {
while($obj = $this->db->fetch_object($res)) while($obj = $this->db->fetch_object($res))
{ {
$this->add_product($obj->fk_product, $obj->fk_entrepot); $this->addProduct($obj->fk_product, $obj->fk_entrepot);
} }
return 1; return 1;
@@ -500,7 +500,7 @@ class Inventory extends CoreObject
/** /**
* Function to get the sql select of inventory * Function to get the sql select of inventory
* @param string $type * @param string $type 'All' to get all data
* @return string * @return string
*/ */
static function getSQL($type) static function getSQL($type)

View File

@@ -33,8 +33,8 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; 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';
$langs->load("stock"); $langs->load('stock');
$langs->load("inventory"); $langs->load('inventory');
if(empty($user->rights->inventory->read)) accessforbidden(); if(empty($user->rights->inventory->read)) accessforbidden();
@@ -58,7 +58,7 @@ function _action()
$inventory = new Inventory($db); $inventory = new Inventory($db);
_card_warehouse( $inventory); card_warehouse( $inventory);
break; break;
@@ -66,17 +66,17 @@ function _action()
if (empty($user->rights->inventory->create)) accessforbidden(); if (empty($user->rights->inventory->create)) accessforbidden();
$inventory = new Inventory($db); $inventory = new Inventory($db);
$inventory->set_values($_POST); $inventory->setValues($_POST);
$fk_inventory = $inventory->create($user); $fk_inventory = $inventory->create($user);
if($fk_inventory>0) { 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->add_products_for($fk_warehouse,$fk_category,$fk_supplier,$only_prods_in_stock); $inventory->addProductsFor($fk_warehouse,$fk_category,$fk_supplier,$only_prods_in_stock);
$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));
@@ -97,7 +97,7 @@ function _action()
$inventory = new Inventory($db); $inventory = new Inventory($db);
$inventory->fetch(GETPOST('id')); $inventory->fetch(GETPOST('id'));
_card($inventory, GETPOST('action')); card($inventory, GETPOST('action'));
break; break;
@@ -110,12 +110,12 @@ function _action()
$inventory = new Inventory($db); $inventory = new Inventory($db);
$inventory->fetch($id); $inventory->fetch($id);
$inventory->set_values($_REQUEST); $inventory->setValues($_REQUEST);
if ($inventory->errors) if ($inventory->errors)
{ {
setEventMessage($inventory->errors, 'errors'); setEventMessage($inventory->errors, 'errors');
_card( $inventory, 'edit'); card( $inventory, 'edit');
} }
else else
{ {
@@ -136,12 +136,12 @@ function _action()
$inventory->status = 1; $inventory->status = 1;
$inventory->update($user); $inventory->update($user);
_card( $inventory, 'view'); card( $inventory, 'view');
} }
else { else {
_card( $inventory, 'view'); card( $inventory, 'view');
} }
break; break;
@@ -155,7 +155,7 @@ function _action()
$inventory->changePMP($user); $inventory->changePMP($user);
_card( $inventory, 'view'); card( $inventory, 'view');
break; break;
@@ -192,7 +192,7 @@ function _action()
} }
if (!$alreadyExists) if (!$alreadyExists)
{ {
if($inventory->add_product($product->id, $fk_warehouse)) { if($inventory->addProduct($product->id, $fk_warehouse)) {
setEventMessage($langs->trans('ProductAdded')); setEventMessage($langs->trans('ProductAdded'));
} }
} }
@@ -204,10 +204,10 @@ function _action()
} }
$inventory->update($user); $inventory->update($user);
$inventory->sort_det(); $inventory->sortDet();
} }
_card( $inventory, 'edit'); card( $inventory, 'edit');
break; break;
@@ -226,7 +226,7 @@ function _action()
$inventory = new Inventory($db); $inventory = new Inventory($db);
$inventory->fetch( $id); $inventory->fetch( $id);
_card($inventory, 'edit'); card($inventory, 'edit');
break; break;
case 'confirm_flush': case 'confirm_flush':
@@ -242,7 +242,7 @@ function _action()
setEventMessage($langs->trans('InventoryFlushed')); setEventMessage($langs->trans('InventoryFlushed'));
_card( $inventory, 'edit'); card( $inventory, 'edit');
break; break;
@@ -283,7 +283,7 @@ function _action()
$inventory = new Inventory($db); $inventory = new Inventory($db);
$inventory->fetch($id); $inventory->fetch($id);
_card($inventory, $action ); card($inventory, $action );
break; break;
@@ -291,7 +291,7 @@ function _action()
} }
function _card_warehouse(&$inventory) function card_warehouse(&$inventory)
{ {
global $langs,$conf,$db, $user, $form; global $langs,$conf,$db, $user, $form;
@@ -346,44 +346,31 @@ function _card_warehouse(&$inventory)
llxFooter(''); llxFooter('');
} }
function _card(&$inventory, $action='edit') function card(&$inventory, $action='edit')
{ {
global $langs, $conf, $db, $user,$form; global $langs, $conf, $db, $user,$form;
llxHeader('',$langs->trans('inventoryEdit'),'',''); llxHeader('',$langs->trans('inventoryEdit'),'','');
if($action == 'changePMP') { if($action == 'changePMP')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id,$langs->trans('ApplyNewPMP') print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id, $langs->trans('ApplyNewPMP'), $langs->trans('ConfirmApplyNewPMP', $inventory->getTitle()), 'confirm_changePMP', array(),'no',1);
,$langs->trans('ConfirmApplyNewPMP',$inventory->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') print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id,$langs->trans('FlushInventory'),$langs->trans('ConfirmFlushInventory',$inventory->getTitle()),'confirm_flush',array(),'no',1);
,$langs->trans('ConfirmFlushInventory',$inventory->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') print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id,$langs->trans('Delete'),$langs->trans('ConfirmDelete',$inventory->getTitle()),'confirm_delete',array(),'no',1);
,$langs->trans('ConfirmDelete',$inventory->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' 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);
,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' print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$inventory->id,$langs->trans('RegulateStock'),$langs->trans('ConfirmRegulateStock',$inventory->getTitle()),'confirm_regulate',array(),'no',1);
,array(),'no',1);
} }
$warehouse = new Entrepot($db); $warehouse = new Entrepot($db);
@@ -392,7 +379,7 @@ function _card(&$inventory, $action='edit')
print dol_get_fiche_head(inventoryPrepareHead($inventory, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), empty($action) ? '': '&action='.$action)); print dol_get_fiche_head(inventoryPrepareHead($inventory, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), empty($action) ? '': '&action='.$action));
$lines = array(); $lines = array();
_card_line($inventory, $lines, $action); card_line($inventory, $lines, $action);
print '<b>'.$langs->trans('inventoryOnDate')." ".$inventory->get_date('date_inventory').'</b><br><br>'; print '<b>'.$langs->trans('inventoryOnDate')." ".$inventory->get_date('date_inventory').'</b><br><br>';
@@ -425,7 +412,7 @@ function _card(&$inventory, $action='edit')
} }
function _card_line(&$inventory, &$lines, $mode) function card_line(&$inventory, &$lines, $mode)
{ {
global $db,$langs,$user,$conf; global $db,$langs,$user,$conf;
$inventory->amount_actual = 0; $inventory->amount_actual = 0;
@@ -452,25 +439,23 @@ function _card_line(&$inventory, &$lines, $mode)
$qty = (float)GETPOST('qty_to_add')[$k]; $qty = (float)GETPOST('qty_to_add')[$k];
$lines[]=array( $lines[]=array(
'produit' => $product->getNomUrl(1).'&nbsp;-&nbsp;'.$product->label 'produit' => $product->getNomUrl(1).'&nbsp;-&nbsp;'.$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'), 'plus16@inventory').'</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),
,'action' => ($user->rights->inventory->write && $mode=='edit' ? '<a href="'.dol_buildpath('inventory/inventory.php?id='.$inventory->id.'&action=delete_line&rowid='.$Inventorydet->id, 1).'">'.img_picto($langs->trans('inventoryDeleteLine'), 'delete').'</a>' : '') 'action' => ($user->rights->inventory->write && $mode=='edit' ? '<a href="'.dol_buildpath('inventory/inventory.php?id='.$inventory->id.'&action=delete_line&rowid='.$Inventorydet->id, 1).'">'.img_picto($langs->trans('inventoryDeleteLine'), 'delete').'</a>' : ''),
,'pmp_stock'=>round($pmp_actual,2) 'pmp_stock'=>round($pmp_actual,2),
,'pmp_actual'=> round($pmp * $Inventorydet->qty_view,2) 'pmp_actual'=> round($pmp * $Inventorydet->qty_view,2),
,'pmp_new'=>(!empty($user->rights->inventory->changePMP && $mode =='edit') ? '<input type="text" name="new_pmp['.$k.']" value="'.$Inventorydet->new_pmp.'" size="8" style="text-align:right;" /> <a id="a_save_new_pmp_'.$k.'" href="javascript:save_pmp('.$k.')">'.img_picto($langs->trans('Save'), 'bt-save.png@inventory').'</a>' : price($Inventorydet->new_pmp)) 'pmp_new'=>(!empty($user->rights->inventory->changePMP) && $mode == 'edit' ? '<input type="text" name="new_pmp['.$k.']" value="'.$Inventorydet->new_pmp.'" size="8" style="text-align:right;" /> <a id="a_save_new_pmp_'.$k.'" href="javascript:save_pmp('.$k.')">'.img_picto($langs->trans('Save'), 'bt-save.png@inventory').'</a>' : price($Inventorydet->new_pmp)),
,'pa_stock'=>round($last_pa * $stock,2) 'pa_stock'=>round($last_pa * $stock,2),
,'pa_actual'=>round($last_pa * $Inventorydet->qty_view,2) 'pa_actual'=>round($last_pa * $Inventorydet->qty_view,2),
,'current_pa_stock'=>round($current_pa * $stock,2) 'current_pa_stock'=>round($current_pa * $stock,2),
,'current_pa_actual'=>round($current_pa * $Inventorydet->qty_view,2) 'current_pa_actual'=>round($current_pa * $Inventorydet->qty_view,2),
'k'=>$k,
,'k'=>$k 'id'=>$Inventorydet->id
,'id'=>$Inventorydet->id
); );
} }

View File

@@ -20,7 +20,6 @@
* \file lib/inventory.lib.php * \file lib/inventory.lib.php
* \ingroup inventory * \ingroup inventory
* \brief This file is an example module library * \brief This file is an example module library
* Put some comments here
*/ */
function inventoryAdminPrepareHead() function inventoryAdminPrepareHead()