Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
ba7fab6ac4
@ -430,7 +430,7 @@ foreach ($list_binding as $key) {
|
|||||||
print $form->selectDate((!empty($conf->global->$key) ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1);
|
print $form->selectDate((!empty($conf->global->$key) ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1);
|
||||||
} elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') {
|
} elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') {
|
||||||
$array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear"));
|
$array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear"));
|
||||||
print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0));
|
print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0), 0, 0, 0, '', 0, 0, 0, '', 'onrightofpage');
|
||||||
} else {
|
} else {
|
||||||
print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
|
print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -339,7 +339,25 @@ if ($modecompta == 'CREANCES-DETTES') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = strtr($formula, $vars);
|
$result = strtr($formula, $vars);
|
||||||
|
$result = str_replace('--', '+', $result);
|
||||||
|
|
||||||
|
if (preg_match('/[a-z]/i', $result)) {
|
||||||
|
$r = 'Error bad formula: '.$result;
|
||||||
|
$rshort = 'Err';
|
||||||
|
print '<td class="liste_total right"><span class="amount" title="'.dol_escape_htmltag($r).'">'.$rshort.'</span></td>';
|
||||||
|
print '<td class="liste_total right"><span class="amount" title="'.dol_escape_htmltag($r).'">'.$rshort.'</span></td>';
|
||||||
|
// Detail by month
|
||||||
|
foreach ($months as $k => $v) {
|
||||||
|
if (($k + 1) >= $date_startmonth) {
|
||||||
|
print '<td class="liste_total right"><span class="amount" title="'.dol_escape_htmltag($r).'">'.$rshort.'</span></td>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($months as $k => $v) {
|
||||||
|
if (($k + 1) < $date_startmonth) {
|
||||||
|
print '<td class="liste_total right"><span class="amount" title="'.dol_escape_htmltag($r).'">'.$rshort.'</span></td>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
//var_dump($result);
|
//var_dump($result);
|
||||||
//$r = $AccCat->calculate($result);
|
//$r = $AccCat->calculate($result);
|
||||||
$r = dol_eval($result, 1, 1, '1');
|
$r = dol_eval($result, 1, 1, '1');
|
||||||
@ -381,6 +399,8 @@ if ($modecompta == 'CREANCES-DETTES') {
|
|||||||
$sommes[$code]['M'][$k] += $r;
|
$sommes[$code]['M'][$k] += $r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach ($months as $k => $v) {
|
foreach ($months as $k => $v) {
|
||||||
if (($k + 1) < $date_startmonth) {
|
if (($k + 1) < $date_startmonth) {
|
||||||
foreach ($sommes as $code => $det) {
|
foreach ($sommes as $code => $det) {
|
||||||
@ -395,6 +415,7 @@ if ($modecompta == 'CREANCES-DETTES') {
|
|||||||
$sommes[$code]['M'][$k] += $r;
|
$sommes[$code]['M'][$k] += $r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
|||||||
@ -3005,7 +3005,7 @@ class Product extends CommonObject
|
|||||||
*
|
*
|
||||||
* @param int $socid Id societe pour filtrer sur une societe
|
* @param int $socid Id societe pour filtrer sur une societe
|
||||||
* @param string $filtrestatut Id statut pour filtrer sur un statut
|
* @param string $filtrestatut Id statut pour filtrer sur un statut
|
||||||
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
|
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation. Set when load_stats_commande is used for virtual stock calculation.
|
||||||
* @return integer Array of stats in $this->stats_commande (nb=nb of order, qty=qty ordered), <0 if ko or >0 if ok
|
* @return integer Array of stats in $this->stats_commande (nb=nb of order, qty=qty ordered), <0 if ko or >0 if ok
|
||||||
*/
|
*/
|
||||||
public function load_stats_commande($socid = 0, $filtrestatut = '', $forVirtualStock = 0)
|
public function load_stats_commande($socid = 0, $filtrestatut = '', $forVirtualStock = 0)
|
||||||
@ -3066,17 +3066,37 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
// If stock decrease is on invoice validation, the theorical stock continue to
|
// If stock decrease is on invoice validation, the theorical stock continue to
|
||||||
// count the orders to ship in theorical stock when some are already removed by invoice validation.
|
// count the orders to ship in theorical stock when some are already removed by invoice validation.
|
||||||
// If option DECREASE_ONLY_UNINVOICEDPRODUCTS is on, we make a compensation.
|
if ($forVirtualStock && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
|
||||||
if (!empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
|
|
||||||
if (!empty($conf->global->DECREASE_ONLY_UNINVOICEDPRODUCTS)) {
|
if (!empty($conf->global->DECREASE_ONLY_UNINVOICEDPRODUCTS)) {
|
||||||
|
// If option DECREASE_ONLY_UNINVOICEDPRODUCTS is on, we make a compensation but only if order not yet invoice.
|
||||||
$adeduire = 0;
|
$adeduire = 0;
|
||||||
$sql = "SELECT sum(fd.qty) as count FROM ".$this->db->prefix()."facturedet fd ";
|
$sql = "SELECT sum(fd.qty) as count FROM ".$this->db->prefix()."facturedet as fd ";
|
||||||
$sql .= " JOIN ".$this->db->prefix()."facture f ON fd.fk_facture = f.rowid ";
|
$sql .= " JOIN ".$this->db->prefix()."facture as f ON fd.fk_facture = f.rowid ";
|
||||||
$sql .= " JOIN ".$this->db->prefix()."element_element el ON el.fk_target = f.rowid and el.targettype = 'facture' and sourcetype = 'commande'";
|
$sql .= " JOIN ".$this->db->prefix()."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))";
|
||||||
$sql .= " JOIN ".$this->db->prefix()."commande c ON el.fk_source = c.rowid ";
|
$sql .= " JOIN ".$this->db->prefix()."commande as c ON el.fk_source = c.rowid ";
|
||||||
$sql .= " WHERE c.fk_statut IN (".$this->db->sanitize($filtrestatut).") AND c.facture = 0 AND fd.fk_product = ".((int) $this->id);
|
$sql .= " WHERE c.fk_statut IN (".$this->db->sanitize($filtrestatut).") AND c.facture = 0 AND fd.fk_product = ".((int) $this->id);
|
||||||
dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE);
|
dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE);
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
if ($this->db->num_rows($resql) > 0) {
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
$adeduire += $obj->count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->stats_commande['qty'] -= $adeduire;
|
||||||
|
} else {
|
||||||
|
// If option DECREASE_ONLY_UNINVOICEDPRODUCTS is off, we make a compensation with lines of invoices linked to the order
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||||
|
|
||||||
|
// For every order having invoice already validated we need to decrease stock cause it's in physical stock
|
||||||
|
$adeduire = 0;
|
||||||
|
$sql = 'SELECT sum(fd.qty) as count FROM '.MAIN_DB_PREFIX.'facturedet as fd ';
|
||||||
|
$sql .= ' JOIN '.MAIN_DB_PREFIX.'facture as f ON fd.fk_facture = f.rowid ';
|
||||||
|
$sql .= ' JOIN '.MAIN_DB_PREFIX."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))";
|
||||||
|
$sql .= ' JOIN '.MAIN_DB_PREFIX.'commande as c ON el.fk_source = c.rowid ';
|
||||||
|
$sql .= ' WHERE c.fk_statut IN ('.$this->db->sanitize($filtrestatut).') AND f.fk_statut > '.Facture::STATUS_DRAFT.' AND fd.fk_product = '.((int) $this->id);
|
||||||
|
dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
if ($this->db->num_rows($resql) > 0) {
|
if ($this->db->num_rows($resql) > 0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user