forked from Wavyzz/dolibarr
Clean code
This commit is contained in:
28
ChangeLog
28
ChangeLog
@@ -2,6 +2,21 @@
|
|||||||
English Dolibarr ChangeLog
|
English Dolibarr ChangeLog
|
||||||
--------------------------------------------------------------
|
--------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
***** ChangeLog for 15.0.0 compared to 14.0.0 *****
|
||||||
|
|
||||||
|
For developers:
|
||||||
|
---------------
|
||||||
|
|
||||||
|
WARNING:
|
||||||
|
|
||||||
|
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
|
||||||
|
* Update hook 'printOriginObjectLine', removed check on product type and special code. Need now reshook.
|
||||||
|
* Old deprecated module "SimplePOS" has been completely removed. Use module "TakePOS" is you need a Point Of Sale.
|
||||||
|
* The method static ActionComm::getActions($db, ...) is no more static. Use $actioncomm->getActions(...) instead (without $db param).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
***** ChangeLog for 14.0.2 compared to 14.0.1 *****
|
***** ChangeLog for 14.0.2 compared to 14.0.1 *****
|
||||||
|
|
||||||
FIX: #18353 Invoice list translation issue
|
FIX: #18353 Invoice list translation issue
|
||||||
@@ -86,19 +101,6 @@ FIX: using Tulip, deposit mask was not saved
|
|||||||
FIX: #yogosha6907
|
FIX: #yogosha6907
|
||||||
|
|
||||||
|
|
||||||
***** ChangeLog for 15.0.0 compared to 14.0.0 *****
|
|
||||||
|
|
||||||
For developers:
|
|
||||||
---------------
|
|
||||||
|
|
||||||
WARNING:
|
|
||||||
|
|
||||||
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
|
|
||||||
* Update hook 'printOriginObjectLine', removed check on product type and special code. Need now reshook.
|
|
||||||
* Old deprecated module "SimplePOS" has been completely removed. Use module "TakePOS" is you need a Point Of Sale.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
***** ChangeLog for 14.0.0 compared to 13.0.0 *****
|
***** ChangeLog for 14.0.0 compared to 13.0.0 *****
|
||||||
|
|
||||||
For users:
|
For users:
|
||||||
|
|||||||
@@ -33,10 +33,6 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php'
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("admin", "trips", "errors", "other", "dict"));
|
$langs->loadLangs(array("admin", "trips", "errors", "other", "dict"));
|
||||||
|
|
||||||
if (!$user->admin) {
|
|
||||||
accessforbidden();
|
|
||||||
}
|
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
@@ -45,10 +41,20 @@ $ikoffset = GETPOST('ikoffset', 'int');
|
|||||||
$coef = GETPOST('coef', 'int');
|
$coef = GETPOST('coef', 'int');
|
||||||
|
|
||||||
$fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat');
|
$fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat');
|
||||||
$fk_range = GETPOST('fk_range');
|
$fk_range = GETPOST('fk_range', 'int');
|
||||||
|
|
||||||
|
$expIk = new ExpenseReportIk($db);
|
||||||
|
|
||||||
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
if ($action == 'updateik') {
|
if ($action == 'updateik') {
|
||||||
$expIk = new ExpenseReportIk($db);
|
|
||||||
if ($id > 0) {
|
if ($id > 0) {
|
||||||
$result = $expIk->fetch($id);
|
$result = $expIk->fetch($id);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
@@ -61,13 +67,13 @@ if ($action == 'updateik') {
|
|||||||
|
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
setEventMessages('SetupSaved', null, 'mesgs');
|
setEventMessages('SetupSaved', null, 'mesgs');
|
||||||
|
|
||||||
header('Location: '.$_SERVER['PHP_SELF']);
|
header('Location: '.$_SERVER['PHP_SELF']);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($expIk->error, $expIk->errors, 'errors');
|
setEventMessages($expIk->error, $expIk->errors, 'errors');
|
||||||
}
|
}
|
||||||
} elseif ($action == 'delete') { // TODO add confirm
|
} elseif ($action == 'delete') { // TODO add confirm
|
||||||
$expIk = new ExpenseReportIk($db);
|
|
||||||
if ($id > 0) {
|
if ($id > 0) {
|
||||||
$result = $expIk->fetch($id);
|
$result = $expIk->fetch($id);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
@@ -77,12 +83,11 @@ if ($action == 'updateik') {
|
|||||||
$expIk->delete($user);
|
$expIk->delete($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
header('Location: '.$_SERVER['PHP_SELF']);
|
header('Location: '.$_SERVER['PHP_SELF']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rangesbycateg = ExpenseReportIk::getAllRanges();
|
$rangesbycateg = $expIk->getAllRanges();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -102,7 +107,8 @@ print dol_get_fiche_head($head, 'expenseik', $langs->trans("ExpenseReportsIk"),
|
|||||||
echo '<span class="opacitymedium">'.$langs->trans('ExpenseReportIkDesc').'</span>';
|
echo '<span class="opacitymedium">'.$langs->trans('ExpenseReportIkDesc').'</span>';
|
||||||
print '<br><br>';
|
print '<br><br>';
|
||||||
|
|
||||||
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
|
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
|
||||||
|
echo '<input type="hidden" name="token" value="'.newToken().'" />';
|
||||||
|
|
||||||
if ($action == 'edit') {
|
if ($action == 'edit') {
|
||||||
echo '<input type="hidden" name="id" value="'.$id.'" />';
|
echo '<input type="hidden" name="id" value="'.$id.'" />';
|
||||||
@@ -111,8 +117,6 @@ if ($action == 'edit') {
|
|||||||
echo '<input type="hidden" name="action" value="updateik" />';
|
echo '<input type="hidden" name="action" value="updateik" />';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<input type="hidden" name="token" value="'.newToken().'" />';
|
|
||||||
|
|
||||||
echo '<table class="noborder centpercent">';
|
echo '<table class="noborder centpercent">';
|
||||||
|
|
||||||
foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) {
|
foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) {
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ $code_expense_rules_type = GETPOST('code_expense_rules_type');
|
|||||||
$dates = dol_mktime(12, 0, 0, GETPOST('startmonth'), GETPOST('startday'), GETPOST('startyear'));
|
$dates = dol_mktime(12, 0, 0, GETPOST('startmonth'), GETPOST('startday'), GETPOST('startyear'));
|
||||||
$datee = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
|
$datee = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
|
||||||
$amount = GETPOST('amount');
|
$amount = GETPOST('amount');
|
||||||
$restrictive = GETPOST('restrictive');
|
|
||||||
|
|
||||||
$object = new ExpenseReportRule($db);
|
$object = new ExpenseReportRule($db);
|
||||||
if (!empty($id)) {
|
if (!empty($id)) {
|
||||||
@@ -138,7 +137,7 @@ if ($action == 'save') {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules = ExpenseReportRule::getAllRule();
|
$rules = $object->getAllRule();
|
||||||
|
|
||||||
$tab_apply = array(
|
$tab_apply = array(
|
||||||
'A' => $langs->trans('All'),
|
'A' => $langs->trans('All'),
|
||||||
|
|||||||
@@ -1245,7 +1245,6 @@ class ActionComm extends CommonObject
|
|||||||
* Load all objects with filters.
|
* Load all objects with filters.
|
||||||
* @todo WARNING: This make a fetch on all records instead of making one request with a join.
|
* @todo WARNING: This make a fetch on all records instead of making one request with a join.
|
||||||
*
|
*
|
||||||
* @param DoliDb $db Not used
|
|
||||||
* @param int $socid Filter by thirdparty
|
* @param int $socid Filter by thirdparty
|
||||||
* @param int $fk_element Id of element action is linked to
|
* @param int $fk_element Id of element action is linked to
|
||||||
* @param string $elementtype Type of element action is linked to
|
* @param string $elementtype Type of element action is linked to
|
||||||
@@ -1255,7 +1254,7 @@ class ActionComm extends CommonObject
|
|||||||
* @param string $limit Limit number of answers
|
* @param string $limit Limit number of answers
|
||||||
* @return array|string Error string if KO, array with actions if OK
|
* @return array|string Error string if KO, array with actions if OK
|
||||||
*/
|
*/
|
||||||
public static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0)
|
public function getActions($socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
@@ -1277,33 +1276,33 @@ class ActionComm extends CommonObject
|
|||||||
$sql .= " (SELECT fk_actioncomm FROM ".MAIN_DB_PREFIX."actioncomm_resources WHERE";
|
$sql .= " (SELECT fk_actioncomm FROM ".MAIN_DB_PREFIX."actioncomm_resources WHERE";
|
||||||
$sql .= " element_type = 'socpeople' AND fk_element = ".((int) $fk_element).')';
|
$sql .= " element_type = 'socpeople' AND fk_element = ".((int) $fk_element).')';
|
||||||
} else {
|
} else {
|
||||||
$sql .= " AND a.fk_element = ".((int) $fk_element)." AND a.elementtype = '".$db->escape($elementtype)."'";
|
$sql .= " AND a.fk_element = ".((int) $fk_element)." AND a.elementtype = '".$this->db->escape($elementtype)."'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($filter)) {
|
if (!empty($filter)) {
|
||||||
$sql .= $filter;
|
$sql .= $filter;
|
||||||
}
|
}
|
||||||
if ($sortorder && $sortfield) {
|
if ($sortorder && $sortfield) {
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
$sql .= $db->plimit($limit, 0);
|
$sql .= $this->db->plimit($limit, 0);
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
|
|
||||||
if ($num) {
|
if ($num) {
|
||||||
for ($i = 0; $i < $num; $i++) {
|
for ($i = 0; $i < $num; $i++) {
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
$actioncommstatic = new ActionComm($db);
|
$actioncommstatic = new ActionComm($this->db);
|
||||||
$actioncommstatic->fetch($obj->id);
|
$actioncommstatic->fetch($obj->id);
|
||||||
$resarray[$i] = $actioncommstatic;
|
$resarray[$i] = $actioncommstatic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->free($resql);
|
$this->db->free($resql);
|
||||||
return $resarray;
|
return $resarray;
|
||||||
} else {
|
} else {
|
||||||
return $db->lasterror();
|
return $this->db->lasterror();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,8 @@ class FormActions
|
|||||||
$sortfield = 'a.datep,a.id';
|
$sortfield = 'a.datep,a.id';
|
||||||
$sortorder = 'DESC,DESC';
|
$sortorder = 'DESC,DESC';
|
||||||
|
|
||||||
$listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0));
|
$actioncomm = new ActionComm($this->db);
|
||||||
|
$listofactions = $actioncomm->getActions($socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0));
|
||||||
if (!is_array($listofactions)) {
|
if (!is_array($listofactions)) {
|
||||||
dol_print_error($this->db, 'FailedToGetActions');
|
dol_print_error($this->db, 'FailedToGetActions');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,10 +300,11 @@ class modMultiCurrency extends DolibarrModules
|
|||||||
{
|
{
|
||||||
global $conf, $user, $langs;
|
global $conf, $user, $langs;
|
||||||
|
|
||||||
if (!MultiCurrency::checkCodeAlreadyExists($conf->currency)) {
|
$multicurrency = new MultiCurrency($this->db);
|
||||||
|
|
||||||
|
if (! $multicurrency->checkCodeAlreadyExists($conf->currency)) {
|
||||||
$langs->loadCacheCurrencies('');
|
$langs->loadCacheCurrencies('');
|
||||||
|
|
||||||
$multicurrency = new MultiCurrency($this->db);
|
|
||||||
$multicurrency->code = $conf->currency;
|
$multicurrency->code = $conf->currency;
|
||||||
$multicurrency->name = $langs->cache_currencies[$conf->currency]['label'].' ('.$langs->getCurrencySymbol($conf->currency).')';
|
$multicurrency->name = $langs->cache_currencies[$conf->currency]['label'].' ('.$langs->getCurrencySymbol($conf->currency).')';
|
||||||
$r = $multicurrency->create($user);
|
$r = $multicurrency->create($user);
|
||||||
|
|||||||
@@ -137,9 +137,16 @@ if ($reshook < 0) {
|
|||||||
|
|
||||||
if (empty($reshook)) {
|
if (empty($reshook)) {
|
||||||
if ($cancel) {
|
if ($cancel) {
|
||||||
|
if ($origin && $origin_id > 0) {
|
||||||
|
if ($origin == 'commande') {
|
||||||
|
header("Location: ".DOL_URL_ROOT.'/expedition/shipment.php?id='.((int) $origin_id));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$action = '';
|
$action = '';
|
||||||
$object->fetch($id); // show shipment also after canceling modification
|
$object->fetch($id); // show shipment also after canceling modification
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
|
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
|
||||||
|
|
||||||
@@ -1049,7 +1056,7 @@ if ($action == 'create') {
|
|||||||
print '<td class="center">'.$langs->trans("QtyShipped").'</td>';
|
print '<td class="center">'.$langs->trans("QtyShipped").'</td>';
|
||||||
print '<td class="center">'.$langs->trans("QtyToShip");
|
print '<td class="center">'.$langs->trans("QtyToShip");
|
||||||
if (empty($conf->productbatch->enabled)) {
|
if (empty($conf->productbatch->enabled)) {
|
||||||
print '<br><a href="#" id="autofill" class="opacitymedium link cursor cursorpointer">'.img_picto($langs->trans("Autofill"), 'autofill', 'class="paddingrightonly"').$langs->trans("Fill").'</a>';
|
print '<br><a href="#" id="autofill" class="opacitymedium link cursor cursorpointer">'.img_picto($langs->trans("Autofill"), 'autofill', 'class="paddingrightonly"').'</a>';
|
||||||
print ' / ';
|
print ' / ';
|
||||||
} else {
|
} else {
|
||||||
print '<br>';
|
print '<br>';
|
||||||
@@ -2482,7 +2489,7 @@ if ($action == 'create') {
|
|||||||
$label = "ClassifyBilled";
|
$label = "ClassifyBilled";
|
||||||
$paramaction = 'classifybilled';
|
$paramaction = 'classifybilled';
|
||||||
}
|
}
|
||||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action='.$paramaction.'">'.$langs->trans($label).'</a>';
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action='.$paramaction.'&token='.newToken().'">'.$langs->trans($label).'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,9 +43,7 @@ if (!empty($conf->propal->enabled)) {
|
|||||||
if (!empty($conf->commande->enabled)) {
|
if (!empty($conf->commande->enabled)) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||||
}
|
}
|
||||||
if (!empty($conf->productbatch->enabled)) {
|
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionlinebatch.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1188,7 +1186,6 @@ class Expedition extends CommonObject
|
|||||||
global $conf, $langs, $user;
|
global $conf, $langs, $user;
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php';
|
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
$this->error = '';
|
$this->error = '';
|
||||||
@@ -1230,6 +1227,9 @@ class Expedition extends CommonObject
|
|||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$cpt = $this->db->num_rows($resql);
|
$cpt = $this->db->num_rows($resql);
|
||||||
|
|
||||||
|
$shipmentlinebatch = new ExpeditionLineBatch($this->db);
|
||||||
|
|
||||||
for ($i = 0; $i < $cpt; $i++) {
|
for ($i = 0; $i < $cpt; $i++) {
|
||||||
dol_syslog(get_class($this)."::delete movement index ".$i);
|
dol_syslog(get_class($this)."::delete movement index ".$i);
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
@@ -1240,7 +1240,7 @@ class Expedition extends CommonObject
|
|||||||
// get lot/serial
|
// get lot/serial
|
||||||
$lotArray = null;
|
$lotArray = null;
|
||||||
if ($conf->productbatch->enabled) {
|
if ($conf->productbatch->enabled) {
|
||||||
$lotArray = ExpeditionLineBatch::fetchAll($this->db, $obj->expeditiondet_id);
|
$lotArray = $shipmentlinebatch->fetchAll($this->db, $obj->expeditiondet_id);
|
||||||
if (!is_array($lotArray)) {
|
if (!is_array($lotArray)) {
|
||||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||||
}
|
}
|
||||||
@@ -1276,7 +1276,8 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
// delete batch expedition line
|
// delete batch expedition line
|
||||||
if (!$error && $conf->productbatch->enabled) {
|
if (!$error && $conf->productbatch->enabled) {
|
||||||
if (ExpeditionLineBatch::deletefromexp($this->db, $this->id) < 0) {
|
$shipmentlinebatch = new ExpeditionLineBatch($this->db);
|
||||||
|
if ($shipmentlinebatch->deleteFromShipment($this->id) < 0) {
|
||||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1372,7 +1373,6 @@ class Expedition extends CommonObject
|
|||||||
global $conf, $langs, $user;
|
global $conf, $langs, $user;
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php';
|
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
$this->error = '';
|
$this->error = '';
|
||||||
@@ -1460,7 +1460,8 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
// delete batch expedition line (we try deletion even if module not enabled in case of the module were enabled and disabled previously)
|
// delete batch expedition line (we try deletion even if module not enabled in case of the module were enabled and disabled previously)
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
if (ExpeditionLineBatch::deletefromexp($this->db, $this->id) < 0) {
|
$shipmentlinebatch = ExpeditionLineBatch($this->db);
|
||||||
|
if ($shipmentlinebatch->deleteFromShipment($this->id) < 0) {
|
||||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1597,6 +1598,7 @@ class Expedition extends CommonObject
|
|||||||
$this->total_localtax2 = 0;
|
$this->total_localtax2 = 0;
|
||||||
|
|
||||||
$line = new ExpeditionLigne($this->db);
|
$line = new ExpeditionLigne($this->db);
|
||||||
|
$shipmentlinebatch = new ExpeditionLineBatch($this->db);
|
||||||
|
|
||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
@@ -1695,9 +1697,8 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
// Detail of batch
|
// Detail of batch
|
||||||
if (!empty($conf->productbatch->enabled) && $obj->line_id > 0 && $obj->product_tobatch > 0) {
|
if (!empty($conf->productbatch->enabled) && $obj->line_id > 0 && $obj->product_tobatch > 0) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php';
|
$newdetailbatch = $shipmentlinebatch->fetchAll($obj->line_id, $obj->fk_product);
|
||||||
|
|
||||||
$newdetailbatch = ExpeditionLineBatch::fetchAll($this->db, $obj->line_id, $obj->fk_product);
|
|
||||||
if (is_array($newdetailbatch)) {
|
if (is_array($newdetailbatch)) {
|
||||||
if ($originline != $obj->fk_origin_line) {
|
if ($originline != $obj->fk_origin_line) {
|
||||||
$line->detail_batch = $newdetailbatch;
|
$line->detail_batch = $newdetailbatch;
|
||||||
@@ -2925,8 +2926,9 @@ class ExpeditionLigne extends CommonObjectLine
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fetch remaining lot qty
|
// fetch remaining lot qty
|
||||||
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php';
|
$shipmentlinebatch = new ExpeditionLineBatch($this->db);
|
||||||
if (!$error && ($lotArray = ExpeditionLineBatch::fetchAll($this->db, $this->id)) < 0) {
|
|
||||||
|
if (!$error && ($lotArray = $shipmentlinebatch->fetchAll($this->id)) < 0) {
|
||||||
$this->errors[] = $this->db->lasterror()." - ExpeditionLineBatch::fetchAll";
|
$this->errors[] = $this->db->lasterror()." - ExpeditionLineBatch::fetchAll";
|
||||||
$error++;
|
$error++;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file expedition/class/expeditionbatch.class.php
|
* \file htdocs/expedition/class/expeditionlinebatch.class.php
|
||||||
* \ingroup productbatch
|
* \ingroup productbatch
|
||||||
* \brief This file implements CRUD method for managing shipment batch lines
|
* \brief This file implements CRUD method for managing shipment batch lines
|
||||||
* with batch record
|
* with batch record
|
||||||
@@ -33,7 +33,10 @@ class ExpeditionLineBatch extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public $element = 'expeditionlignebatch';
|
public $element = 'expeditionlignebatch';
|
||||||
|
|
||||||
private static $_table_element = 'expeditiondet_batch'; //!< Name of table without prefix where object is stored
|
/**
|
||||||
|
* @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
|
||||||
|
*/
|
||||||
|
public $table_element = 'expeditiondet_batch';
|
||||||
|
|
||||||
public $sellby;
|
public $sellby;
|
||||||
public $eatby;
|
public $eatby;
|
||||||
@@ -44,6 +47,7 @@ class ExpeditionLineBatch extends CommonObject
|
|||||||
public $fk_origin_stock;
|
public $fk_origin_stock;
|
||||||
public $fk_expeditiondet;
|
public $fk_expeditiondet;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@@ -74,6 +78,7 @@ class ExpeditionLineBatch extends CommonObject
|
|||||||
$sql .= " WHERE pb.rowid = ".(int) $id_stockdluo;
|
$sql .= " WHERE pb.rowid = ".(int) $id_stockdluo;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
if ($this->db->num_rows($resql)) {
|
if ($this->db->num_rows($resql)) {
|
||||||
@@ -106,7 +111,7 @@ class ExpeditionLineBatch extends CommonObject
|
|||||||
|
|
||||||
$id_line_expdet = (int) $id_line_expdet;
|
$id_line_expdet = (int) $id_line_expdet;
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX.self::$_table_element." (";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (";
|
||||||
$sql .= "fk_expeditiondet";
|
$sql .= "fk_expeditiondet";
|
||||||
$sql .= ", sellby";
|
$sql .= ", sellby";
|
||||||
$sql .= ", eatby";
|
$sql .= ", eatby";
|
||||||
@@ -129,7 +134,8 @@ class ExpeditionLineBatch extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.self::$_table_element);
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
|
||||||
|
|
||||||
$this->fk_expeditiondet = $id_line_expdet;
|
$this->fk_expeditiondet = $id_line_expdet;
|
||||||
return $this->id;
|
return $this->id;
|
||||||
} else {
|
} else {
|
||||||
@@ -145,17 +151,16 @@ class ExpeditionLineBatch extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Delete batch record attach to a shipment
|
* Delete batch record attach to a shipment
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database object
|
|
||||||
* @param int $id_expedition rowid of shipment
|
* @param int $id_expedition rowid of shipment
|
||||||
* @return int -1 if KO, 1 if OK
|
* @return int -1 if KO, 1 if OK
|
||||||
*/
|
*/
|
||||||
public static function deletefromexp($db, $id_expedition)
|
public function deleteFromShipment($id_expedition)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX.self::$_table_element;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
|
||||||
$sql .= " WHERE fk_expeditiondet in (SELECT rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition=".((int) $id_expedition).")";
|
$sql .= " WHERE fk_expeditiondet in (SELECT rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition=".((int) $id_expedition).")";
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
if ($db->query($sql)) {
|
if ($this->db->query($sql)) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -165,12 +170,11 @@ class ExpeditionLineBatch extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Retrieve all batch number detailed information of a shipment line
|
* Retrieve all batch number detailed information of a shipment line
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database object
|
|
||||||
* @param int $id_line_expdet id of shipment line
|
* @param int $id_line_expdet id of shipment line
|
||||||
* @param int $fk_product If provided, load also detailed information of lot
|
* @param int $fk_product If provided, load also detailed information of lot
|
||||||
* @return int|array -1 if KO, array of ExpeditionLineBatch if OK
|
* @return int|array -1 if KO, array of ExpeditionLineBatch if OK
|
||||||
*/
|
*/
|
||||||
public static function fetchAll($db, $id_line_expdet, $fk_product = 0)
|
public function fetchAll($id_line_expdet, $fk_product = 0)
|
||||||
{
|
{
|
||||||
$sql = "SELECT";
|
$sql = "SELECT";
|
||||||
$sql .= " eb.rowid,";
|
$sql .= " eb.rowid,";
|
||||||
@@ -184,25 +188,24 @@ class ExpeditionLineBatch extends CommonObject
|
|||||||
$sql .= ", pl.sellby";
|
$sql .= ", pl.sellby";
|
||||||
$sql .= ", pl.eatby";
|
$sql .= ", pl.eatby";
|
||||||
}
|
}
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as eb";
|
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as eb";
|
||||||
if ($fk_product > 0) {
|
if ($fk_product > 0) {
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON pl.batch = eb.batch AND pl.fk_product = ".((int) $fk_product);
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON pl.batch = eb.batch AND pl.fk_product = ".((int) $fk_product);
|
||||||
}
|
}
|
||||||
$sql .= " WHERE fk_expeditiondet=".(int) $id_line_expdet;
|
$sql .= " WHERE fk_expeditiondet=".(int) $id_line_expdet;
|
||||||
|
|
||||||
dol_syslog(__METHOD__."", LOG_DEBUG);
|
dol_syslog(__METHOD__."", LOG_DEBUG);
|
||||||
$resql = $db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$ret = array();
|
$ret = array();
|
||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$tmp = new self($db);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$obj = $db->fetch_object($resql);
|
$tmp = new self($this->db);
|
||||||
|
$tmp->sellby = $this->db->jdate($obj->sellby ? $obj->sellby : $obj->oldsellby);
|
||||||
$tmp->sellby = $db->jdate($obj->sellby ? $obj->sellby : $obj->oldsellby);
|
$tmp->eatby = $this->db->jdate($obj->eatby ? $obj->eatby : $obj->oldeatby);
|
||||||
$tmp->eatby = $db->jdate($obj->eatby ? $obj->eatby : $obj->oldeatby);
|
|
||||||
$tmp->batch = $obj->batch;
|
$tmp->batch = $obj->batch;
|
||||||
$tmp->id = $obj->rowid;
|
$tmp->id = $obj->rowid;
|
||||||
$tmp->fk_origin_stock = $obj->fk_origin_stock;
|
$tmp->fk_origin_stock = $obj->fk_origin_stock;
|
||||||
@@ -213,10 +216,12 @@ class ExpeditionLineBatch extends CommonObject
|
|||||||
$ret[] = $tmp;
|
$ret[] = $tmp;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$db->free($resql);
|
|
||||||
|
$this->db->free($resql);
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($this->db);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,8 @@ if (empty($fk_expense) || $fk_expense < 0) {
|
|||||||
if ($userauthor->fetch($expense->fk_user_author) <= 0) {
|
if ($userauthor->fetch($expense->fk_user_author) <= 0) {
|
||||||
echo json_encode(array('error' => $langs->transnoentitiesnoconv('ErrorRecordNotFound'), 'fk_user_author' => $expense->fk_user_author));
|
echo json_encode(array('error' => $langs->transnoentitiesnoconv('ErrorRecordNotFound'), 'fk_user_author' => $expense->fk_user_author));
|
||||||
} else {
|
} else {
|
||||||
$range = ExpenseReportIk::getRangeByUser($userauthor, $fk_c_exp_tax_cat);
|
$expenseik = new ExpenseReportIk($db);
|
||||||
|
$range = $expenseik->getRangeByUser($userauthor, $fk_c_exp_tax_cat);
|
||||||
|
|
||||||
if (empty($range)) {
|
if (empty($range)) {
|
||||||
echo json_encode(array('error' => $langs->transnoentitiesnoconv('ErrorRecordNotFound'), 'range' => $range));
|
echo json_encode(array('error' => $langs->transnoentitiesnoconv('ErrorRecordNotFound'), 'range' => $range));
|
||||||
|
|||||||
@@ -1887,7 +1887,8 @@ class ExpenseReport extends CommonObject
|
|||||||
}
|
}
|
||||||
//$buyer = new Societe($this->db);
|
//$buyer = new Societe($this->db);
|
||||||
|
|
||||||
$rulestocheck = ExpenseReportRule::getAllRule($this->line->fk_c_type_fees, $this->line->date, $this->fk_user_author);
|
$expensereportrule = new ExpenseReportRule($db);
|
||||||
|
$rulestocheck = $expensereportrule->getAllRule($this->line->fk_c_type_fees, $this->line->date, $this->fk_user_author);
|
||||||
|
|
||||||
$violation = 0;
|
$violation = 0;
|
||||||
$rule_warning_message_tab = array();
|
$rule_warning_message_tab = array();
|
||||||
@@ -1974,7 +1975,8 @@ class ExpenseReport extends CommonObject
|
|||||||
}
|
}
|
||||||
//$buyer = new Societe($this->db);
|
//$buyer = new Societe($this->db);
|
||||||
|
|
||||||
$range = ExpenseReportIk::getRangeByUser($userauthor, $this->line->fk_c_exp_tax_cat);
|
$expenseik = new ExpenseReportIk($db);
|
||||||
|
$range = $expenseik->getRangeByUser($userauthor, $this->line->fk_c_exp_tax_cat);
|
||||||
|
|
||||||
if (empty($range)) {
|
if (empty($range)) {
|
||||||
$this->error = 'ErrorNoRangeAvailable';
|
$this->error = 'ErrorNoRangeAvailable';
|
||||||
|
|||||||
@@ -87,8 +87,6 @@ class ExpenseReportIk extends CoreObject
|
|||||||
*/
|
*/
|
||||||
public function __construct(DoliDB &$db)
|
public function __construct(DoliDB &$db)
|
||||||
{
|
{
|
||||||
global $conf;
|
|
||||||
|
|
||||||
parent::__construct($db);
|
parent::__construct($db);
|
||||||
parent::init();
|
parent::init();
|
||||||
|
|
||||||
@@ -102,29 +100,28 @@ class ExpenseReportIk extends CoreObject
|
|||||||
* @param int $mode 1=only active; 2=only inactive; other value return all
|
* @param int $mode 1=only active; 2=only inactive; other value return all
|
||||||
* @return array of category
|
* @return array of category
|
||||||
*/
|
*/
|
||||||
public static function getTaxCategories($mode = 1)
|
public function getTaxCategories($mode = 1)
|
||||||
{
|
{
|
||||||
global $db;
|
|
||||||
|
|
||||||
$categories = array();
|
$categories = array();
|
||||||
|
|
||||||
$sql = 'SELECT rowid, label, entity, active';
|
$sql = 'SELECT rowid, label, entity, active';
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat';
|
$sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat';
|
||||||
$sql .= ' WHERE entity IN ('.getEntity('c_exp_tax_cat').')';
|
$sql .= ' WHERE entity IN (0, '.getEntity($this->element).')';
|
||||||
if ($mode == 1) {
|
if ($mode == 1) {
|
||||||
$sql .= ' AND active = 1';
|
$sql .= ' AND active = 1';
|
||||||
} elseif ($mode == 2) {
|
} elseif ($mode == 2) {
|
||||||
$sql .= 'AND active = 0';
|
$sql .= 'AND active = 0';
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog(get_called_class().'::getTaxCategories sql='.$sql, LOG_DEBUG);
|
dol_syslog(get_called_class().'::getTaxCategories', LOG_DEBUG);
|
||||||
$resql = $db->query($sql);
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
while ($obj = $db->fetch_object($resql)) {
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
$categories[$obj->rowid] = $obj;
|
$categories[$obj->rowid] = $obj;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $categories;
|
return $categories;
|
||||||
@@ -137,10 +134,10 @@ class ExpenseReportIk extends CoreObject
|
|||||||
* @param int $fk_c_exp_tax_cat category
|
* @param int $fk_c_exp_tax_cat category
|
||||||
* @return boolean|array
|
* @return boolean|array
|
||||||
*/
|
*/
|
||||||
public static function getRangeByUser(User $userauthor, int $fk_c_exp_tax_cat)
|
public function getRangeByUser(User $userauthor, int $fk_c_exp_tax_cat)
|
||||||
{
|
{
|
||||||
$default_range = (int) $userauthor->default_range; // if not defined, then 0
|
$default_range = (int) $userauthor->default_range; // if not defined, then 0
|
||||||
$ranges = self::getRangesByCategory($fk_c_exp_tax_cat);
|
$ranges = $this->getRangesByCategory($fk_c_exp_tax_cat);
|
||||||
|
|
||||||
// substract 1 because array start from 0
|
// substract 1 because array start from 0
|
||||||
if (empty($ranges) || !isset($ranges[$default_range - 1])) {
|
if (empty($ranges) || !isset($ranges[$default_range - 1])) {
|
||||||
@@ -157,10 +154,8 @@ class ExpenseReportIk extends CoreObject
|
|||||||
* @param int $active active
|
* @param int $active active
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getRangesByCategory(int $fk_c_exp_tax_cat, $active = 1)
|
public function getRangesByCategory(int $fk_c_exp_tax_cat, $active = 1)
|
||||||
{
|
{
|
||||||
global $db;
|
|
||||||
|
|
||||||
$ranges = array();
|
$ranges = array();
|
||||||
|
|
||||||
dol_syslog(get_called_class().'::getRangesByCategory for fk_c_exp_tax_cat='.$fk_c_exp_tax_cat, LOG_DEBUG);
|
dol_syslog(get_called_class().'::getRangesByCategory for fk_c_exp_tax_cat='.$fk_c_exp_tax_cat, LOG_DEBUG);
|
||||||
@@ -170,24 +165,25 @@ class ExpenseReportIk extends CoreObject
|
|||||||
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)';
|
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)';
|
||||||
}
|
}
|
||||||
$sql .= ' WHERE r.fk_c_exp_tax_cat = '.((int) $fk_c_exp_tax_cat);
|
$sql .= ' WHERE r.fk_c_exp_tax_cat = '.((int) $fk_c_exp_tax_cat);
|
||||||
|
$sql .= " AND entity IN(0, ".getEntity($this->element).")";
|
||||||
if ($active) {
|
if ($active) {
|
||||||
$sql .= ' AND r.active = 1 AND c.active = 1';
|
$sql .= ' AND r.active = 1 AND c.active = 1';
|
||||||
}
|
}
|
||||||
$sql .= ' ORDER BY r.range_ik';
|
$sql .= ' ORDER BY r.range_ik';
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
if ($num > 0) {
|
if ($num > 0) {
|
||||||
while ($obj = $db->fetch_object($resql)) {
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
$object = new ExpenseReportIk($db);
|
$object = new ExpenseReportIk($this->db);
|
||||||
$object->fetch($obj->rowid);
|
$object->fetch($obj->rowid);
|
||||||
|
|
||||||
$ranges[] = $object;
|
$ranges[] = $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ranges;
|
return $ranges;
|
||||||
@@ -198,24 +194,23 @@ class ExpenseReportIk extends CoreObject
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getAllRanges()
|
public function getAllRanges()
|
||||||
{
|
{
|
||||||
global $db;
|
|
||||||
|
|
||||||
$ranges = array();
|
$ranges = array();
|
||||||
|
|
||||||
$sql = ' SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, c.label, i.rowid as fk_expense_ik, r.active as range_active, c.active as cat_active';
|
$sql = ' SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, c.label, i.rowid as fk_expense_ik, r.active as range_active, c.active as cat_active';
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r';
|
$sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r';
|
||||||
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)';
|
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)';
|
||||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expensereport_ik i ON (r.rowid = i.fk_range)';
|
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expensereport_ik i ON (r.rowid = i.fk_range)';
|
||||||
$sql .= ' WHERE r.entity IN (0, '.getEntity('').')';
|
$sql .= ' WHERE r.entity IN (0, '.getEntity($this->element).')';
|
||||||
$sql .= ' ORDER BY r.fk_c_exp_tax_cat, r.range_ik';
|
$sql .= ' ORDER BY r.fk_c_exp_tax_cat, r.range_ik';
|
||||||
|
|
||||||
dol_syslog(get_called_class().'::getAllRanges sql='.$sql, LOG_DEBUG);
|
dol_syslog(get_called_class().'::getAllRanges', LOG_DEBUG);
|
||||||
$resql = $db->query($sql);
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
while ($obj = $db->fetch_object($resql)) {
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
$ik = new ExpenseReportIk($db);
|
$ik = new ExpenseReportIk($this->db);
|
||||||
if ($obj->fk_expense_ik > 0) {
|
if ($obj->fk_expense_ik > 0) {
|
||||||
$ik->fetch($obj->fk_expense_ik);
|
$ik->fetch($obj->fk_expense_ik);
|
||||||
}
|
}
|
||||||
@@ -227,7 +222,7 @@ class ExpenseReportIk extends CoreObject
|
|||||||
$ranges[$obj->fk_c_exp_tax_cat]['ranges'][] = $obj;
|
$ranges[$obj->fk_c_exp_tax_cat]['ranges'][] = $obj;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ranges;
|
return $ranges;
|
||||||
@@ -236,30 +231,28 @@ class ExpenseReportIk extends CoreObject
|
|||||||
/**
|
/**
|
||||||
* Return the max number of range by a category
|
* Return the max number of range by a category
|
||||||
*
|
*
|
||||||
* @param int $default_c_exp_tax_cat id
|
* @param int $default_c_exp_tax_cat id Default c_exp_tax_cat
|
||||||
* @return int
|
* @return int Max nb
|
||||||
*/
|
*/
|
||||||
public static function getMaxRangeNumber($default_c_exp_tax_cat = 0)
|
public function getMaxRangeNumber($default_c_exp_tax_cat = 0)
|
||||||
{
|
{
|
||||||
global $db, $conf;
|
|
||||||
|
|
||||||
$sql = 'SELECT MAX(counted) as nbRange FROM (';
|
$sql = 'SELECT MAX(counted) as nbRange FROM (';
|
||||||
$sql .= ' SELECT COUNT(*) as counted';
|
$sql .= ' SELECT COUNT(*) as counted';
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r';
|
$sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r';
|
||||||
$sql .= ' WHERE r.entity IN (0, '.$conf->entity.')';
|
$sql .= ' WHERE r.entity IN (0, '.getEntity($this->element).')';
|
||||||
if ($default_c_exp_tax_cat > 0) {
|
if ($default_c_exp_tax_cat > 0) {
|
||||||
$sql .= ' AND r.fk_c_exp_tax_cat = '.((int) $default_c_exp_tax_cat);
|
$sql .= ' AND r.fk_c_exp_tax_cat = '.((int) $default_c_exp_tax_cat);
|
||||||
}
|
}
|
||||||
$sql .= ' GROUP BY r.fk_c_exp_tax_cat';
|
$sql .= ' GROUP BY r.fk_c_exp_tax_cat';
|
||||||
$sql .= ') as counts';
|
$sql .= ') as counts';
|
||||||
|
|
||||||
dol_syslog(get_called_class().'::getMaxRangeNumber sql='.$sql, LOG_DEBUG);
|
dol_syslog(get_called_class().'::getMaxRangeNumber', LOG_DEBUG);
|
||||||
$resql = $db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
return $obj->nbRange;
|
return $obj->nbRange;
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -148,20 +148,19 @@ class ExpenseReportRule extends CoreObject
|
|||||||
* @param int $fk_user user of expense
|
* @param int $fk_user user of expense
|
||||||
* @return array Array with ExpenseReportRule
|
* @return array Array with ExpenseReportRule
|
||||||
*/
|
*/
|
||||||
public static function getAllRule($fk_c_type_fees = '', $date = '', $fk_user = '')
|
public function getAllRule($fk_c_type_fees = '', $date = '', $fk_user = '')
|
||||||
{
|
{
|
||||||
global $db;
|
|
||||||
|
|
||||||
$rules = array();
|
$rules = array();
|
||||||
|
|
||||||
$sql = 'SELECT er.rowid';
|
$sql = 'SELECT er.rowid';
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_rules er';
|
$sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_rules er';
|
||||||
$sql .= ' WHERE er.entity IN (0,'.getEntity('').')';
|
$sql .= ' WHERE er.entity IN (0,'.getEntity($this->element).')';
|
||||||
if (!empty($fk_c_type_fees)) {
|
if (!empty($fk_c_type_fees)) {
|
||||||
$sql .= ' AND er.fk_c_type_fees IN (-1, '.((int) $fk_c_type_fees).')';
|
$sql .= ' AND er.fk_c_type_fees IN (-1, '.((int) $fk_c_type_fees).')';
|
||||||
}
|
}
|
||||||
if (!empty($date)) {
|
if (!empty($date)) {
|
||||||
$sql .= " AND er.dates <= '".dol_print_date($date, '%Y-%m-%d')."'";
|
$sql .= " AND er.dates <= '".$this->db->idate($date)."'";
|
||||||
$sql .= " AND er.datee >= '".dol_print_date($date, '%Y-%m-%d')."'";
|
$sql .= " AND er.datee >= '".$this->db->idate($date)."'";
|
||||||
}
|
}
|
||||||
if ($fk_user > 0) {
|
if ($fk_user > 0) {
|
||||||
$sql .= ' AND (er.is_for_all = 1';
|
$sql .= ' AND (er.is_for_all = 1';
|
||||||
@@ -172,18 +171,18 @@ class ExpenseReportRule extends CoreObject
|
|||||||
|
|
||||||
dol_syslog("ExpenseReportRule::getAllRule");
|
dol_syslog("ExpenseReportRule::getAllRule");
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
while ($obj = $db->fetch_object($resql)) {
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
$rule = new ExpenseReportRule($db);
|
$rule = new ExpenseReportRule($this->db);
|
||||||
if ($rule->fetch($obj->rowid) > 0) {
|
if ($rule->fetch($obj->rowid) > 0) {
|
||||||
$rules[$rule->id] = $rule;
|
$rules[$rule->id] = $rule;
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
@@ -201,7 +200,7 @@ class ExpenseReportRule extends CoreObject
|
|||||||
if ($this->fk_usergroup > 0) {
|
if ($this->fk_usergroup > 0) {
|
||||||
$group = new UserGroup($this->db);
|
$group = new UserGroup($this->db);
|
||||||
if ($group->fetch($this->fk_usergroup) > 0) {
|
if ($group->fetch($this->fk_usergroup) > 0) {
|
||||||
return $group->nom;
|
return $group->name;
|
||||||
} else {
|
} else {
|
||||||
$this->error = $group->error;
|
$this->error = $group->error;
|
||||||
$this->errors[] = $this->error;
|
$this->errors[] = $this->error;
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ ShipmentClassifyClosedInDolibarr=Shipment %s classified billed
|
|||||||
ShipmentUnClassifyCloseddInDolibarr=Shipment %s classified re-open
|
ShipmentUnClassifyCloseddInDolibarr=Shipment %s classified re-open
|
||||||
ShipmentBackToDraftInDolibarr=Shipment %s go back to draft status
|
ShipmentBackToDraftInDolibarr=Shipment %s go back to draft status
|
||||||
ShipmentDeletedInDolibarr=Shipment %s deleted
|
ShipmentDeletedInDolibarr=Shipment %s deleted
|
||||||
|
ShipmentCanceledInDolibarr=Shipment %s canceled
|
||||||
ReceptionValidatedInDolibarr=Reception %s validated
|
ReceptionValidatedInDolibarr=Reception %s validated
|
||||||
OrderCreatedInDolibarr=Order %s created
|
OrderCreatedInDolibarr=Order %s created
|
||||||
OrderValidatedInDolibarr=Order %s validated
|
OrderValidatedInDolibarr=Order %s validated
|
||||||
|
|||||||
@@ -506,7 +506,11 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt(
|
|||||||
} else {
|
} else {
|
||||||
dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (POST method or GET with a sensible value for 'action' parameter) in main.inc.php. Token not provided.", LOG_WARNING);
|
dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (POST method or GET with a sensible value for 'action' parameter) in main.inc.php. Token not provided.", LOG_WARNING);
|
||||||
print "Access to this page this way (POST method or GET with a sensible value for 'action' parameter) is refused by CSRF protection in main.inc.php. Token not provided.\n";
|
print "Access to this page this way (POST method or GET with a sensible value for 'action' parameter) is refused by CSRF protection in main.inc.php. Token not provided.\n";
|
||||||
print "If you access your server behind a proxy using url rewriting and the parameter is provided by caller, you might check that all HTTP header are propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file or MAIN_SECURITY_CSRF_WITH_TOKEN to 0 into setup).\n";
|
print "If you access your server behind a proxy using url rewriting and the parameter is provided by caller, you might check that all HTTP header are propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file or MAIN_SECURITY_CSRF_WITH_TOKEN to 0";
|
||||||
|
if (! empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) {
|
||||||
|
print " instead of ".$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN;
|
||||||
|
}
|
||||||
|
print " into setup).\n";
|
||||||
}
|
}
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ class MultiCurrency extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function addRateFromDolibarr($code, $rate)
|
public function addRateFromDolibarr($code, $rate)
|
||||||
{
|
{
|
||||||
global $db, $user;
|
global $user;
|
||||||
|
|
||||||
$currency = new MultiCurrency($this->db);
|
$currency = new MultiCurrency($this->db);
|
||||||
$currency->code = $code;
|
$currency->code = $code;
|
||||||
@@ -441,8 +441,8 @@ class MultiCurrency extends CommonObject
|
|||||||
$sql = 'SELECT label FROM '.MAIN_DB_PREFIX."c_currencies WHERE code_iso = '".$this->db->escape($code)."'";
|
$sql = 'SELECT label FROM '.MAIN_DB_PREFIX."c_currencies WHERE code_iso = '".$this->db->escape($code)."'";
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
$resql = $db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql && ($line = $db->fetch_object($resql))) {
|
if ($resql && ($line = $this->db->fetch_object($resql))) {
|
||||||
$currency->name = $line->label;
|
$currency->name = $line->label;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -687,12 +687,10 @@ class MultiCurrency extends CommonObject
|
|||||||
* @param string $code current code to search
|
* @param string $code current code to search
|
||||||
* @return boolean True if exists, false if not exists
|
* @return boolean True if exists, false if not exists
|
||||||
*/
|
*/
|
||||||
public static function checkCodeAlreadyExists($code)
|
public function checkCodeAlreadyExists($code)
|
||||||
{
|
{
|
||||||
global $db;
|
$currencytmp = new MultiCurrency($this->db);
|
||||||
|
if ($currencytmp->fetch('', $code) > 0) {
|
||||||
$currency = new MultiCurrency($db);
|
|
||||||
if ($currency->fetch('', $code) > 0) {
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -2026,7 +2026,7 @@ if ($action == 'create') {
|
|||||||
$label = "ClassifyBilled";
|
$label = "ClassifyBilled";
|
||||||
$paramaction = 'classifybilled';
|
$paramaction = 'classifybilled';
|
||||||
}
|
}
|
||||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action='.$paramaction.'">'.$langs->trans($label).'</a>';
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action='.$paramaction.'&token='.newToken().'">'.$langs->trans($label).'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -339,7 +339,10 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
|
|||||||
$ret .= '<input type="hidden" name="action" value="setdefault_range">';
|
$ret .= '<input type="hidden" name="action" value="setdefault_range">';
|
||||||
$ret .= '<input type="hidden" name="token" value="'.newToken().'">';
|
$ret .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
$ret .= '<input type="hidden" name="id" value="'.$object->id.'">';
|
$ret .= '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||||
$maxRangeNum = ExpenseReportIk::getMaxRangeNumber($object->default_c_exp_tax_cat);
|
|
||||||
|
$expensereportik = new ExpenseReportIk($db);
|
||||||
|
$maxRangeNum = $expensereportik->getMaxRangeNumber($object->default_c_exp_tax_cat);
|
||||||
|
|
||||||
$ret .= $form->selectarray('default_range', range(0, $maxRangeNum), $object->default_range);
|
$ret .= $form->selectarray('default_range', range(0, $maxRangeNum), $object->default_range);
|
||||||
$ret .= '<input type="submit" class="button" name="modify" value="'.$langs->trans("Modify").'"> ';
|
$ret .= '<input type="submit" class="button" name="modify" value="'.$langs->trans("Modify").'"> ';
|
||||||
$ret .= '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
|
$ret .= '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||||
|
|||||||
@@ -201,7 +201,6 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
|
|||||||
|| in_array($file['name'], array('modules_boxes.php', 'rapport.pdf.php', 'TraceableDB.php'))) {
|
|| in_array($file['name'], array('modules_boxes.php', 'rapport.pdf.php', 'TraceableDB.php'))) {
|
||||||
if (! in_array($file['name'], array(
|
if (! in_array($file['name'], array(
|
||||||
'api.class.php',
|
'api.class.php',
|
||||||
'actioncomm.class.php',
|
|
||||||
'commonobject.class.php',
|
'commonobject.class.php',
|
||||||
'conf.class.php',
|
'conf.class.php',
|
||||||
'html.form.class.php',
|
'html.form.class.php',
|
||||||
@@ -213,16 +212,13 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
|
|||||||
'modules_product.class.php',
|
'modules_product.class.php',
|
||||||
'modules_societe.class.php',
|
'modules_societe.class.php',
|
||||||
'TraceableDB.php',
|
'TraceableDB.php',
|
||||||
'expeditionbatch.class.php',
|
|
||||||
'expensereport_ik.class.php',
|
|
||||||
'expensereport_rule.class.php',
|
|
||||||
'multicurrency.class.php',
|
'multicurrency.class.php',
|
||||||
'productbatch.class.php',
|
'productbatch.class.php',
|
||||||
'reception.class.php',
|
'reception.class.php',
|
||||||
'societe.class.php' ,
|
'societe.class.php' ,
|
||||||
'account.class.php'
|
'account.class.php'
|
||||||
))) {
|
))) {
|
||||||
// Must must not found $db->
|
// Must not found $db->
|
||||||
$ok=true;
|
$ok=true;
|
||||||
$matches=array();
|
$matches=array();
|
||||||
// Check string $db-> inside a class.php file (it should be $this->db-> insto such classes)
|
// Check string $db-> inside a class.php file (it should be $this->db-> insto such classes)
|
||||||
|
|||||||
Reference in New Issue
Block a user