Add function "convertDurationtoHour"
This commit is contained in:
parent
8a36e2e9d8
commit
c068eebc43
@ -24,6 +24,7 @@
|
|||||||
// Put here all includes required by your class file
|
// Put here all includes required by your class file
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
|
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
|
||||||
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||||
|
|
||||||
@ -1128,13 +1129,7 @@ class BOM extends CommonObject
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
//Convert qty to hour
|
//Convert qty to hour
|
||||||
if($line->duration_unit == 's') $qty = $line->qty / 3600;
|
$qty = convertDurationtoHour($line->qty, $line->duration_unit);
|
||||||
if($line->duration_unit == 'i') $qty = $line->qty / 60;
|
|
||||||
if($line->duration_unit == 'h') $qty = $line->qty;
|
|
||||||
if($line->duration_unit == 'd') $qty = $line->qty * 24;
|
|
||||||
if($line->duration_unit == 'w') $qty = $line->qty * 24 * 7;
|
|
||||||
if($line->duration_unit == 'm') $qty = $line->qty * 730.484;
|
|
||||||
if($line->duration_unit == 'y') $qty = $line->qty * 365 * 24;
|
|
||||||
|
|
||||||
if($conf->workstation->enabled){
|
if($conf->workstation->enabled){
|
||||||
if($tmpproduct->fk_default_workstation) {
|
if($tmpproduct->fk_default_workstation) {
|
||||||
|
|||||||
@ -318,6 +318,27 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Convert duration to hour
|
||||||
|
*
|
||||||
|
* @param int $duration_value Duration value
|
||||||
|
* @param int $duration_unit Duration unit
|
||||||
|
* @return int $result
|
||||||
|
*/
|
||||||
|
function convertDurationtoHour($duration_value, $duration_unit)
|
||||||
|
{
|
||||||
|
$result = 0;
|
||||||
|
|
||||||
|
if($duration_unit == 's') $result = $duration_value / 3600;
|
||||||
|
if($duration_unit == 'i') $result = $duration_value / 60;
|
||||||
|
if($duration_unit == 'h') $result = $duration_value;
|
||||||
|
if($duration_unit == 'd') $result = $duration_value * 24;
|
||||||
|
if($duration_unit == 'w') $result = $duration_value * 24 * 7;
|
||||||
|
if($duration_unit == 'm') $result = $duration_value * 730.484;
|
||||||
|
if($duration_unit == 'y') $result = $duration_value * 365 * 24;
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a SQL string to make a filter into a range (for second of date until last second of date).
|
* Generate a SQL string to make a filter into a range (for second of date until last second of date).
|
||||||
* This method allows to maje SQL request that will deal correctly the timezone of server.
|
* This method allows to maje SQL request that will deal correctly the timezone of server.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user