Compatibility - Remove WITH
This commit is contained in:
parent
409a114038
commit
035f7c57c4
@ -652,6 +652,7 @@ class Asset extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
$sql = "WITH in_accounting_bookkeeping(fk_docdet) AS (";
|
$sql = "WITH in_accounting_bookkeeping(fk_docdet) AS (";
|
||||||
$sql .= " SELECT DISTINCT fk_docdet";
|
$sql .= " SELECT DISTINCT fk_docdet";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
|
||||||
@ -663,6 +664,14 @@ class Asset extends CommonObject
|
|||||||
$sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid";
|
$sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid";
|
||||||
$sql .= " WHERE ad.fk_asset = " . (int) $this->id;
|
$sql .= " WHERE ad.fk_asset = " . (int) $this->id;
|
||||||
$sql .= " ORDER BY ad.depreciation_date ASC";
|
$sql .= " ORDER BY ad.depreciation_date ASC";
|
||||||
|
*/
|
||||||
|
|
||||||
|
$sql = "SELECT ad.rowid, ad.depreciation_mode, ad.ref, ad.depreciation_date, ad.depreciation_ht, ad.cumulative_depreciation_ht";
|
||||||
|
$sql .= ", " . $this->db->ifsql('iab.fk_docdet IS NOT NULL', 1, 0) . " AS bookkeeping";
|
||||||
|
$sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad";
|
||||||
|
$sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid";
|
||||||
|
$sql .= " WHERE ad.fk_asset = " . (int) $this->id;
|
||||||
|
$sql .= " ORDER BY ad.depreciation_date ASC";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
@ -708,6 +717,7 @@ class Asset extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
$sql = "WITH in_accounting_bookkeeping(fk_docdet) AS (";
|
$sql = "WITH in_accounting_bookkeeping(fk_docdet) AS (";
|
||||||
$sql .= " SELECT DISTINCT fk_docdet";
|
$sql .= " SELECT DISTINCT fk_docdet";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
|
||||||
@ -718,6 +728,13 @@ class Asset extends CommonObject
|
|||||||
$sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid";
|
$sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid";
|
||||||
$sql .= " WHERE ad.fk_asset = " . (int) $this->id;
|
$sql .= " WHERE ad.fk_asset = " . (int) $this->id;
|
||||||
$sql .= " AND iab.fk_docdet IS NOT NULL";
|
$sql .= " AND iab.fk_docdet IS NOT NULL";
|
||||||
|
*/
|
||||||
|
|
||||||
|
$sql = "SELECT COUNT(*) AS has_bookkeeping";
|
||||||
|
$sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad";
|
||||||
|
$sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid";
|
||||||
|
$sql .= " WHERE ad.fk_asset = " . (int) $this->id;
|
||||||
|
$sql .= " AND iab.fk_docdet IS NOT NULL";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
@ -866,6 +883,7 @@ class Asset extends CommonObject
|
|||||||
foreach ($options->deprecation_options as $mode_key => $fields) {
|
foreach ($options->deprecation_options as $mode_key => $fields) {
|
||||||
// Get last depreciation lines save in bookkeeping
|
// Get last depreciation lines save in bookkeeping
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
|
/*
|
||||||
$sql = "WITH in_accounting_bookkeeping(fk_docdet) AS (";
|
$sql = "WITH in_accounting_bookkeeping(fk_docdet) AS (";
|
||||||
$sql .= " SELECT fk_docdet";
|
$sql .= " SELECT fk_docdet";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
|
||||||
@ -879,6 +897,17 @@ class Asset extends CommonObject
|
|||||||
$sql .= " AND iab.fk_docdet IS NOT NULL";
|
$sql .= " AND iab.fk_docdet IS NOT NULL";
|
||||||
$sql .= " ORDER BY ad.depreciation_date DESC";
|
$sql .= " ORDER BY ad.depreciation_date DESC";
|
||||||
$sql .= " LIMIT 1";
|
$sql .= " LIMIT 1";
|
||||||
|
*/
|
||||||
|
|
||||||
|
$sql = "SELECT ad.depreciation_date, ad.cumulative_depreciation_ht";
|
||||||
|
$sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad";
|
||||||
|
$sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid";
|
||||||
|
$sql .= " WHERE ad.fk_asset = " . (int) $this->id;
|
||||||
|
$sql .= " AND ad.depreciation_mode = '" . $this->db->escape($mode_key) . "'";
|
||||||
|
$sql .= " AND iab.fk_docdet IS NOT NULL";
|
||||||
|
$sql .= " ORDER BY ad.depreciation_date DESC";
|
||||||
|
$sql .= " LIMIT 1";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
$this->errors[] = $langs->trans('AssetErrorFetchMaxDepreciationDateForMode', $mode_key) . ': ' . $this->db->lasterror();
|
$this->errors[] = $langs->trans('AssetErrorFetchMaxDepreciationDateForMode', $mode_key) . ': ' . $this->db->lasterror();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user