Merge branch 'dolibarrdevelop' into WIP_Employee_management_improvement
This commit is contained in:
commit
5bf186c8ce
@ -663,7 +663,7 @@ if ($action == 'create') {
|
||||
// Also, it is not possible to use a value that is not in the list.
|
||||
// Also, the label is not automatically filled when a value is selected.
|
||||
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
|
||||
print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1);
|
||||
print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label');
|
||||
} else {
|
||||
print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">';
|
||||
}
|
||||
@ -746,7 +746,7 @@ if ($action == 'create') {
|
||||
// Also, it is not possible to use a value that is not in the list.
|
||||
// Also, the label is not automatically filled when a value is selected.
|
||||
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
|
||||
print $formaccounting->select_auxaccount('', 'subledger_account', 1);
|
||||
print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label');
|
||||
} else {
|
||||
print '<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccount")) . '">';
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
/* Copyright (C) 2017-2022 OpenDSI <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -81,6 +81,24 @@ class AccountingJournal extends CommonObject
|
||||
*/
|
||||
public $lines;
|
||||
|
||||
/**
|
||||
* @var array Accounting account cached
|
||||
*/
|
||||
static public $accounting_account_cached = array();
|
||||
|
||||
/**
|
||||
* @var array Nature mapping
|
||||
*/
|
||||
static public $nature_maps = array(
|
||||
1 => 'variousoperations',
|
||||
2 => 'sells',
|
||||
3 => 'purchases',
|
||||
4 => 'bank',
|
||||
5 => 'expensereports',
|
||||
8 => 'inventories',
|
||||
9 => 'hasnew',
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -345,4 +363,680 @@ class AccountingJournal extends CommonObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get journal data
|
||||
*
|
||||
* @param User $user User who get infos
|
||||
* @param string $type Type data returned ('view', 'bookkeeping', 'csv')
|
||||
* @param int $date_start Filter 'start date'
|
||||
* @param int $date_end Filter 'end date'
|
||||
* @param string $in_bookkeeping Filter 'in bookkeeping' ('already', 'notyet')
|
||||
* @return array|int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function getData(User $user, $type = 'view', $date_start = null, $date_end = null, $in_bookkeeping = 'notyet')
|
||||
{
|
||||
global $hookmanager;
|
||||
|
||||
// Clean parameters
|
||||
if (empty($type)) $type = 'view';
|
||||
if (empty($in_bookkeeping)) $in_bookkeeping = 'notyet';
|
||||
|
||||
// Hook
|
||||
if (!is_object($hookmanager)) {
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
|
||||
$data = array();
|
||||
|
||||
$hookmanager->initHooks(array('accountingjournaldao'));
|
||||
$parameters = array('data' => &$data, 'user' => $user, 'type' => $type, 'date_start' => $date_start, 'date_end' => $date_end, 'in_bookkeeping' => $in_bookkeeping);
|
||||
$reshook = $hookmanager->executeHooks('getData', $parameters, $this); // Note that $action and $object may have been
|
||||
if ($reshook < 0) {
|
||||
$this->error = $hookmanager->error;
|
||||
$this->errors = $hookmanager->errors;
|
||||
return -1;
|
||||
} elseif (empty($reshook)) {
|
||||
switch ($this->nature) {
|
||||
case 1: // Various Journal
|
||||
$data = $this->getAssetData($user, $type, $date_start, $date_end, $in_bookkeeping);
|
||||
break;
|
||||
// case 2: // Sells Journal
|
||||
// case 3: // Purchases Journal
|
||||
// case 4: // Bank Journal
|
||||
// case 5: // Expense reports Journal
|
||||
// case 8: // Inventory Journal
|
||||
// case 9: // hasnew Journal
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get asset data for various journal
|
||||
*
|
||||
* @param User $user User who get infos
|
||||
* @param string $type Type data returned ('view', 'bookkeeping', 'csv')
|
||||
* @param int $date_start Filter 'start date'
|
||||
* @param int $date_end Filter 'end date'
|
||||
* @param string $in_bookkeeping Filter 'in bookkeeping' ('already', 'notyet')
|
||||
* @return array|int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function getAssetData(User $user, $type = 'view', $date_start = null, $date_end = null, $in_bookkeeping = 'notyet')
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
if (empty($conf->asset->enabled)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetaccountancycodes.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetdepreciationoptions.class.php';
|
||||
|
||||
$langs->loadLangs(array("assets"));
|
||||
|
||||
// Clean parameters
|
||||
if (empty($type)) $type = 'view';
|
||||
if (empty($in_bookkeeping)) $in_bookkeeping = 'notyet';
|
||||
|
||||
$sql = "";
|
||||
if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') {
|
||||
$sql .= "WITH in_accounting_bookkeeping(fk_docdet) AS (";
|
||||
$sql .= " SELECT DISTINCT fk_docdet";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
|
||||
$sql .= " WHERE doc_type = 'asset'";
|
||||
$sql .= ")";
|
||||
}
|
||||
$sql .= "SELECT ad.fk_asset AS rowid, a.ref AS asset_ref, a.label AS asset_label, a.acquisition_value_ht AS asset_acquisition_value_ht";
|
||||
$sql .= ", a.disposal_date AS asset_disposal_date, a.disposal_amount_ht AS asset_disposal_amount_ht, a.disposal_subject_to_vat AS asset_disposal_subject_to_vat";
|
||||
$sql .= ", ad.rowid AS depreciation_id, ad.depreciation_mode, ad.ref AS depreciation_ref, ad.depreciation_date, ad.depreciation_ht, ad.accountancy_code_debit, ad.accountancy_code_credit";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation as ad";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "asset as a ON a.rowid = ad.fk_asset";
|
||||
if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') {
|
||||
$sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid";
|
||||
}
|
||||
$sql .= " WHERE a.entity IN (" . getEntity('asset', 0) . ')'; // We don't share object for accountancy, we use source object sharing
|
||||
$sql .= " AND ad.ref != ''"; // not reversal lines
|
||||
if ($date_start && $date_end) {
|
||||
$sql .= " AND ad.depreciation_date >= '" . $this->db->idate($date_start) . "' AND ad.depreciation_date <= '" . $this->db->idate($date_end) . "'";
|
||||
}
|
||||
// Define begin binding date
|
||||
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
|
||||
$sql .= " AND ad.depreciation_date >= '" . $this->db->idate($conf->global->ACCOUNTING_DATE_START_BINDING) . "'";
|
||||
}
|
||||
// Already in bookkeeping or not
|
||||
if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') {
|
||||
$sql .= " AND iab.fk_docdet IS" . ($in_bookkeeping == 'already' ? " NOT" : "") . " NULL";
|
||||
}
|
||||
$sql .= " ORDER BY ad.depreciation_date";
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
|
||||
$pre_data = array(
|
||||
'elements' => array(),
|
||||
);
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
if (!isset($pre_data['elements'][$obj->rowid])) {
|
||||
$pre_data['elements'][$obj->rowid] = array(
|
||||
'ref' => $obj->asset_ref,
|
||||
'label' => $obj->asset_label,
|
||||
'acquisition_value_ht' => $obj->asset_acquisition_value_ht,
|
||||
'depreciation' => array(),
|
||||
);
|
||||
|
||||
// Disposal infos
|
||||
if (isset($obj->asset_disposal_date)) {
|
||||
$pre_data['elements'][$obj->rowid]['disposal'] = array(
|
||||
'date' => $this->db->jdate($obj->asset_disposal_date),
|
||||
'amount' => $obj->asset_disposal_amount_ht,
|
||||
'subject_to_vat' => !empty($obj->asset_disposal_subject_to_vat),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$compta_debit = empty($obj->accountancy_code_debit) ? 'NotDefined' : $obj->accountancy_code_debit;
|
||||
$compta_credit = empty($obj->accountancy_code_credit) ? 'NotDefined' : $obj->accountancy_code_credit;
|
||||
|
||||
$pre_data['elements'][$obj->rowid]['depreciation'][$obj->depreciation_id] = array(
|
||||
'date' => $this->db->jdate($obj->depreciation_date),
|
||||
'ref' => $obj->depreciation_ref,
|
||||
'lines' => array(
|
||||
$compta_debit => -$obj->depreciation_ht,
|
||||
$compta_credit => $obj->depreciation_ht,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$disposal_ref = $langs->transnoentitiesnoconv('AssetDisposal');
|
||||
$journal = $this->code;
|
||||
$journal_label = $this->label;
|
||||
$journal_label_formatted = $langs->transnoentities($journal_label);
|
||||
$now = dol_now();
|
||||
|
||||
$element_static = new Asset($this->db);
|
||||
|
||||
$journal_data = array();
|
||||
foreach ($pre_data['elements'] as $pre_data_id => $pre_data_info) {
|
||||
$element_static->id = $pre_data_id;
|
||||
$element_static->ref = (string) $pre_data_info["ref"];
|
||||
$element_static->label = (string) $pre_data_info["label"];
|
||||
$element_static->acquisition_value_ht = $pre_data_info["acquisition_value_ht"];
|
||||
$element_link = $element_static->getNomUrl(1, 'with_label');
|
||||
|
||||
$element_name_formatted_0 = dol_trunc($element_static->label, 16);
|
||||
$element_name_formatted_1 = utf8_decode(dol_trunc($element_static->label, 32));
|
||||
$element_name_formatted_2 = utf8_decode(dol_trunc($element_static->label, 16));
|
||||
$label_operation = $element_static->getNomUrl(0, 'label', 16);
|
||||
|
||||
$element = array(
|
||||
'ref' => dol_trunc($element_static->ref, 16, 'right', 'UTF-8', 1),
|
||||
'error' => $pre_data_info['error'],
|
||||
'blocks' => array(),
|
||||
);
|
||||
|
||||
// Depreciation lines
|
||||
//--------------------
|
||||
foreach ($pre_data_info['depreciation'] as $depreciation_id => $line) {
|
||||
$depreciation_ref = $line["ref"];
|
||||
$depreciation_date = $line["date"];
|
||||
$depreciation_date_formatted = dol_print_date($depreciation_date, 'day');
|
||||
|
||||
// lines
|
||||
$blocks = array();
|
||||
foreach ($line['lines'] as $account => $mt) {
|
||||
$account_infos = $this->getAccountingAccountInfos($account);
|
||||
|
||||
if ($type == 'view') {
|
||||
$account_to_show = length_accounta($account);
|
||||
if (($account_to_show == "") || $account_to_show == 'NotDefined') {
|
||||
$account_to_show = '<span class="error">' . $langs->trans("AssetInAccountNotDefined") . '</span>';
|
||||
}
|
||||
|
||||
$blocks[] = array(
|
||||
'date' => $depreciation_date_formatted,
|
||||
'piece' => $element_link,
|
||||
'account_accounting' => $account_to_show,
|
||||
'subledger_account' => '',
|
||||
'label_operation' => $label_operation . ' - ' . $depreciation_ref,
|
||||
'debit' => $mt < 0 ? price(-$mt) : '',
|
||||
'credit' => $mt >= 0 ? price($mt) : '',
|
||||
);
|
||||
} elseif ($type == 'bookkeeping') {
|
||||
if ($account_infos['found']) {
|
||||
$blocks[] = array(
|
||||
'doc_date' => $depreciation_date,
|
||||
'date_lim_reglement' => '',
|
||||
'doc_ref' => $element_static->ref,
|
||||
'date_creation' => $now,
|
||||
'doc_type' => 'asset',
|
||||
'fk_doc' => $element_static->id,
|
||||
'fk_docdet' => $depreciation_id, // Useless, can be several lines that are source of this record to add
|
||||
'thirdparty_code' => '',
|
||||
'subledger_account' => '',
|
||||
'subledger_label' => '',
|
||||
'numero_compte' => $account,
|
||||
'label_compte' => $account_infos['label'],
|
||||
'label_operation' => $element_name_formatted_0 . ' - ' . $depreciation_ref,
|
||||
'montant' => $mt,
|
||||
'sens' => $mt < 0 ? 'D' : 'C',
|
||||
'debit' => $mt < 0 ? -$mt : 0,
|
||||
'credit' => $mt >= 0 ? $mt : 0,
|
||||
'code_journal' => $journal,
|
||||
'journal_label' => $journal_label_formatted,
|
||||
'piece_num' => '',
|
||||
'import_key' => '',
|
||||
'fk_user_author' => $user->id,
|
||||
'entity' => $conf->entity,
|
||||
);
|
||||
}
|
||||
} else { // $type == 'csv'
|
||||
$blocks[] = array(
|
||||
$depreciation_date, // Date
|
||||
$element_static->ref, // Piece
|
||||
$account_infos['code_formatted_1'], // AccountAccounting
|
||||
$element_name_formatted_0 . ' - ' . $depreciation_ref, // LabelOperation
|
||||
$mt < 0 ? price(-$mt) : '', // Debit
|
||||
$mt >= 0 ? price($mt) : '', // Credit
|
||||
);
|
||||
}
|
||||
}
|
||||
$element['blocks'][] = $blocks;
|
||||
}
|
||||
|
||||
// Disposal line
|
||||
//--------------------
|
||||
if (!empty($pre_data_info['disposal'])) {
|
||||
$disposal_date = $pre_data_info['disposal']['date'];
|
||||
|
||||
if ((!($date_start && $date_end) || ($date_start <= $disposal_date && $disposal_date <= $date_end)) &&
|
||||
(empty($conf->global->ACCOUNTING_DATE_START_BINDING) || $conf->global->ACCOUNTING_DATE_START_BINDING <= $disposal_date)
|
||||
) {
|
||||
$disposal_amount = $pre_data_info['disposal']['amount'];
|
||||
$disposal_subject_to_vat = $pre_data_info['disposal']['subject_to_vat'];
|
||||
$disposal_date_formatted = dol_print_date($disposal_date, 'day');
|
||||
$disposal_vat = $conf->global->ASSET_DISPOSAL_VAT > 0 ? $conf->global->ASSET_DISPOSAL_VAT : 20;
|
||||
|
||||
// Get accountancy codes
|
||||
//---------------------------
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetaccountancycodes.class.php';
|
||||
$accountancy_codes = new AssetAccountancyCodes($this->db);
|
||||
$result = $accountancy_codes->fetchAccountancyCodes($element_static->id);
|
||||
if ($result < 0) {
|
||||
$element['error'] = $accountancy_codes->errorsToString();
|
||||
} else {
|
||||
// Get last depreciation cumulative amount
|
||||
$element_static->fetchDepreciationLines();
|
||||
foreach ($element_static->depreciation_lines as $mode_key => $depreciation_lines) {
|
||||
$accountancy_codes_list = $accountancy_codes->accountancy_codes[$mode_key];
|
||||
|
||||
if (!isset($accountancy_codes_list['value_asset_sold'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$accountancy_code_value_asset_sold = empty($accountancy_codes_list['value_asset_sold']) ? 'NotDefined' : $accountancy_codes_list['value_asset_sold'];
|
||||
$accountancy_code_depreciation_asset = empty($accountancy_codes_list['depreciation_asset']) ? 'NotDefined' : $accountancy_codes_list['depreciation_asset'];
|
||||
$accountancy_code_asset = empty($accountancy_codes_list['asset']) ? 'NotDefined' : $accountancy_codes_list['asset'];
|
||||
$accountancy_code_receivable_on_assignment = empty($accountancy_codes_list['receivable_on_assignment']) ? 'NotDefined' : $accountancy_codes_list['receivable_on_assignment'];
|
||||
$accountancy_code_vat_collected = empty($accountancy_codes_list['vat_collected']) ? 'NotDefined' : $accountancy_codes_list['vat_collected'];
|
||||
$accountancy_code_proceeds_from_sales = empty($accountancy_codes_list['proceeds_from_sales']) ? 'NotDefined' : $accountancy_codes_list['proceeds_from_sales'];
|
||||
|
||||
$last_cumulative_amount_ht = 0;
|
||||
$depreciated_ids = array_keys($pre_data_info['depreciation']);
|
||||
foreach ($depreciation_lines as $line) {
|
||||
$last_cumulative_amount_ht = $line['cumulative_depreciation_ht'];
|
||||
if (!in_array($line['id'], $depreciated_ids) && empty($line['bookkeeping']) && !empty($line['ref'])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$lines = array();
|
||||
$lines[0][$accountancy_code_value_asset_sold] = -($element_static->acquisition_value_ht - $last_cumulative_amount_ht);
|
||||
$lines[0][$accountancy_code_depreciation_asset] = -$last_cumulative_amount_ht;
|
||||
$lines[0][$accountancy_code_asset] = $element_static->acquisition_value_ht;
|
||||
|
||||
$disposal_amount_vat = $disposal_subject_to_vat ? (double) price2num($disposal_amount * $disposal_vat / 100, 'MT') : 0;
|
||||
$lines[1][$accountancy_code_receivable_on_assignment] = -($disposal_amount + $disposal_amount_vat);
|
||||
if ($disposal_subject_to_vat) $lines[1][$accountancy_code_vat_collected] = $disposal_amount_vat;
|
||||
$lines[1][$accountancy_code_proceeds_from_sales] = $disposal_amount;
|
||||
|
||||
foreach ($lines as $lines_block) {
|
||||
$blocks = array();
|
||||
foreach ($lines_block as $account => $mt) {
|
||||
$account_infos = $this->getAccountingAccountInfos($account);
|
||||
|
||||
if ($type == 'view') {
|
||||
$account_to_show = length_accounta($account);
|
||||
if (($account_to_show == "") || $account_to_show == 'NotDefined') {
|
||||
$account_to_show = '<span class="error">' . $langs->trans("AssetInAccountNotDefined") . '</span>';
|
||||
}
|
||||
|
||||
$blocks[] = array(
|
||||
'date' => $disposal_date_formatted,
|
||||
'piece' => $element_link,
|
||||
'account_accounting' => $account_to_show,
|
||||
'subledger_account' => '',
|
||||
'label_operation' => $label_operation . ' - ' . $disposal_ref,
|
||||
'debit' => $mt < 0 ? price(-$mt) : '',
|
||||
'credit' => $mt >= 0 ? price($mt) : '',
|
||||
);
|
||||
} elseif ($type == 'bookkeeping') {
|
||||
if ($account_infos['found']) {
|
||||
$blocks[] = array(
|
||||
'doc_date' => $disposal_date,
|
||||
'date_lim_reglement' => '',
|
||||
'doc_ref' => $element_static->ref,
|
||||
'date_creation' => $now,
|
||||
'doc_type' => 'asset',
|
||||
'fk_doc' => $element_static->id,
|
||||
'fk_docdet' => 0, // Useless, can be several lines that are source of this record to add
|
||||
'thirdparty_code' => '',
|
||||
'subledger_account' => '',
|
||||
'subledger_label' => '',
|
||||
'numero_compte' => $account,
|
||||
'label_compte' => $account_infos['label'],
|
||||
'label_operation' => $element_name_formatted_0 . ' - ' . $disposal_ref,
|
||||
'montant' => $mt,
|
||||
'sens' => $mt < 0 ? 'D' : 'C',
|
||||
'debit' => $mt < 0 ? -$mt : 0,
|
||||
'credit' => $mt >= 0 ? $mt : 0,
|
||||
'code_journal' => $journal,
|
||||
'journal_label' => $journal_label_formatted,
|
||||
'piece_num' => '',
|
||||
'import_key' => '',
|
||||
'fk_user_author' => $user->id,
|
||||
'entity' => $conf->entity,
|
||||
);
|
||||
}
|
||||
} else { // $type == 'csv'
|
||||
$blocks[] = array(
|
||||
$disposal_date, // Date
|
||||
$element_static->ref, // Piece
|
||||
$account_infos['code_formatted_1'], // AccountAccounting
|
||||
$element_name_formatted_0 . ' - ' . $disposal_ref, // LabelOperation
|
||||
$mt < 0 ? price(-$mt) : '', // Debit
|
||||
$mt >= 0 ? price($mt) : '', // Credit
|
||||
);
|
||||
}
|
||||
}
|
||||
$element['blocks'][] = $blocks;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$journal_data[$pre_data_id] = $element;
|
||||
}
|
||||
unset($pre_data);
|
||||
|
||||
return $journal_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write bookkeeping
|
||||
*
|
||||
* @param User $user User who write in the bookkeeping
|
||||
* @param array $journal_data Journal data to write in the bookkeeping
|
||||
* $journal_data = array(
|
||||
* id_element => array(
|
||||
* 'ref' => 'ref',
|
||||
* 'error' => '',
|
||||
* 'blocks' => array(
|
||||
* pos_block => array(
|
||||
* num_line => array(
|
||||
* 'doc_date' => '',
|
||||
* 'date_lim_reglement' => '',
|
||||
* 'doc_ref' => '',
|
||||
* 'date_creation' => '',
|
||||
* 'doc_type' => '',
|
||||
* 'fk_doc' => '',
|
||||
* 'fk_docdet' => '',
|
||||
* 'thirdparty_code' => '',
|
||||
* 'subledger_account' => '',
|
||||
* 'subledger_label' => '',
|
||||
* 'numero_compte' => '',
|
||||
* 'label_compte' => '',
|
||||
* 'label_operation' => '',
|
||||
* 'montant' => '',
|
||||
* 'sens' => '',
|
||||
* 'debit' => '',
|
||||
* 'credit' => '',
|
||||
* 'code_journal' => '',
|
||||
* 'journal_label' => '',
|
||||
* 'piece_num' => '',
|
||||
* 'import_key' => '',
|
||||
* 'fk_user_author' => '',
|
||||
* 'entity' => '',
|
||||
* ),
|
||||
* ),
|
||||
* ),
|
||||
* ),
|
||||
* );
|
||||
* @param int $max_nb_errors Nb error authorized before stop the process
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function writeIntoBookkeeping(User $user, &$journal_data = array(), $max_nb_errors = 10)
|
||||
{
|
||||
global $conf, $langs, $hookmanager;
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
||||
|
||||
// Hook
|
||||
if (!is_object($hookmanager)) {
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
$hookmanager->initHooks(array('accountingjournaldao'));
|
||||
$parameters = array('journal_data' => &$journal_data);
|
||||
$reshook = $hookmanager->executeHooks('writeBookkeeping', $parameters, $this); // Note that $action and $object may have been
|
||||
if ($reshook < 0) {
|
||||
$this->error = $hookmanager->error;
|
||||
$this->errors = $hookmanager->errors;
|
||||
return -1;
|
||||
} elseif (empty($reshook)) {
|
||||
// Clean parameters
|
||||
$journal_data = is_array($journal_data) ? $journal_data : array();
|
||||
|
||||
foreach ($journal_data as $element_id => $element) {
|
||||
$error_for_line = 0;
|
||||
$total_credit = 0;
|
||||
$total_debit = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if ($element['error'] == 'somelinesarenotbound') {
|
||||
$error++;
|
||||
$error_for_line++;
|
||||
$this->errors[] = $langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $element['ref']);
|
||||
}
|
||||
|
||||
if (!$error_for_line) {
|
||||
foreach ($element['blocks'] as $lines) {
|
||||
foreach ($lines as $line) {
|
||||
$bookkeeping = new BookKeeping($this->db);
|
||||
$bookkeeping->doc_date = $line['doc_date'];
|
||||
$bookkeeping->date_lim_reglement = $line['date_lim_reglement'];
|
||||
$bookkeeping->doc_ref = $line['doc_ref'];
|
||||
$bookkeeping->date_creation = $line['date_creation']; // not used
|
||||
$bookkeeping->doc_type = $line['doc_type'];
|
||||
$bookkeeping->fk_doc = $line['fk_doc'];
|
||||
$bookkeeping->fk_docdet = $line['fk_docdet'];
|
||||
$bookkeeping->thirdparty_code = $line['thirdparty_code'];
|
||||
$bookkeeping->subledger_account = $line['subledger_account'];
|
||||
$bookkeeping->subledger_label = $line['subledger_label'];
|
||||
$bookkeeping->numero_compte = $line['numero_compte'];
|
||||
$bookkeeping->label_compte = $line['label_compte'];
|
||||
$bookkeeping->label_operation = $line['label_operation'];
|
||||
$bookkeeping->montant = $line['montant'];
|
||||
$bookkeeping->sens = $line['sens'];
|
||||
$bookkeeping->debit = $line['debit'];
|
||||
$bookkeeping->credit = $line['credit'];
|
||||
$bookkeeping->code_journal = $line['code_journal'];
|
||||
$bookkeeping->journal_label = $line['journal_label'];
|
||||
$bookkeeping->piece_num = $line['piece_num'];
|
||||
$bookkeeping->import_key = $line['import_key'];
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
$bookkeeping->entity = $conf->entity;
|
||||
|
||||
$total_debit += $bookkeeping->debit;
|
||||
$total_credit += $bookkeeping->credit;
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
|
||||
$error++;
|
||||
$error_for_line++;
|
||||
$journal_data[$element_id]['error'] = 'alreadyjournalized';
|
||||
} else {
|
||||
$error++;
|
||||
$error_for_line++;
|
||||
$journal_data[$element_id]['error'] = 'other';
|
||||
$this->errors[] = $bookkeeping->errorsToString();
|
||||
}
|
||||
}
|
||||
//
|
||||
// if (!$error_for_line && !empty($conf->asset->enabled) && $this->nature == 1 && $bookkeeping->fk_doc > 0) {
|
||||
// // Set last cumulative depreciation
|
||||
// require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php';
|
||||
// $asset = new Asset($this->db);
|
||||
// $result = $asset->setLastCumulativeDepreciation($bookkeeping->fk_doc);
|
||||
// if ($result < 0) {
|
||||
// $error++;
|
||||
// $error_for_line++;
|
||||
// $journal_data[$element_id]['error'] = 'other';
|
||||
// $this->errors[] = $asset->errorsToString();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
if ($error_for_line) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Protection against a bug on lines before
|
||||
if (!$error_for_line && (price2num($total_debit, 'MT') != price2num($total_credit, 'MT'))) {
|
||||
$error++;
|
||||
$error_for_line++;
|
||||
$journal_data[$element_id]['error'] = 'amountsnotbalanced';
|
||||
$this->errors[] = 'Try to insert a non balanced transaction in book for ' . $element['blocks'] . '. Canceled. Surely a bug.';
|
||||
}
|
||||
|
||||
if (!$error_for_line) {
|
||||
$this->db->commit();
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
|
||||
if ($error >= $max_nb_errors) {
|
||||
$this->errors[] = $langs->trans("ErrorTooManyErrorsProcessStopped");
|
||||
break; // Break in the foreach
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $error ? -$error : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export journal CSV
|
||||
* ISO and not UTF8 !
|
||||
*
|
||||
* @param array $journal_data Journal data to write in the bookkeeping
|
||||
* $journal_data = array(
|
||||
* id_element => array(
|
||||
* 'continue' => false,
|
||||
* 'blocks' => array(
|
||||
* pos_block => array(
|
||||
* num_line => array(
|
||||
* data to write in the CSV line
|
||||
* ),
|
||||
* ),
|
||||
* ),
|
||||
* ),
|
||||
* );
|
||||
* @param int $search_date_end Search date end
|
||||
* @param string $sep CSV separator
|
||||
* @return int|string <0 if KO, >0 if OK
|
||||
*/
|
||||
public function exportCsv(&$journal_data = array(), $search_date_end = 0, $sep = '')
|
||||
{
|
||||
global $conf, $langs, $hookmanager;
|
||||
|
||||
if (empty($sep)) $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
$out = '';
|
||||
|
||||
// Hook
|
||||
if (!is_object($hookmanager)) {
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
|
||||
$hookmanager->initHooks(array('accountingjournaldao'));
|
||||
$parameters = array('journal_data' => &$journal_data, 'search_date_end' => &$search_date_end, 'sep' => &$sep, 'out' => &$out);
|
||||
$reshook = $hookmanager->executeHooks('exportCsv', $parameters, $this); // Note that $action and $object may have been
|
||||
if ($reshook < 0) {
|
||||
$this->error = $hookmanager->error;
|
||||
$this->errors = $hookmanager->errors;
|
||||
return -1;
|
||||
} elseif (empty($reshook)) {
|
||||
// Clean parameters
|
||||
$journal_data = is_array($journal_data) ? $journal_data : array();
|
||||
|
||||
// CSV header line
|
||||
$header = array();
|
||||
if ($this->nature == 4) {
|
||||
$header = array(
|
||||
$langs->transnoentitiesnoconv("BankId"),
|
||||
$langs->transnoentitiesnoconv("Date"),
|
||||
$langs->transnoentitiesnoconv("PaymentMode"),
|
||||
$langs->transnoentitiesnoconv("AccountAccounting"),
|
||||
$langs->transnoentitiesnoconv("LedgerAccount"),
|
||||
$langs->transnoentitiesnoconv("SubledgerAccount"),
|
||||
$langs->transnoentitiesnoconv("Label"),
|
||||
$langs->transnoentitiesnoconv("Debit"),
|
||||
$langs->transnoentitiesnoconv("Credit"),
|
||||
$langs->transnoentitiesnoconv("Journal"),
|
||||
$langs->transnoentitiesnoconv("Note"),
|
||||
);
|
||||
} elseif ($this->nature == 5) {
|
||||
$header = array(
|
||||
$langs->transnoentitiesnoconv("Date"),
|
||||
$langs->transnoentitiesnoconv("Piece"),
|
||||
$langs->transnoentitiesnoconv("AccountAccounting"),
|
||||
$langs->transnoentitiesnoconv("LabelOperation"),
|
||||
$langs->transnoentitiesnoconv("Debit"),
|
||||
$langs->transnoentitiesnoconv("Credit"),
|
||||
);
|
||||
} elseif ($this->nature == 1) {
|
||||
$header = array(
|
||||
$langs->transnoentitiesnoconv("Date"),
|
||||
$langs->transnoentitiesnoconv("Piece"),
|
||||
$langs->transnoentitiesnoconv("AccountAccounting"),
|
||||
$langs->transnoentitiesnoconv("LabelOperation"),
|
||||
$langs->transnoentitiesnoconv("Debit"),
|
||||
$langs->transnoentitiesnoconv("Credit"),
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($header)) $out .= '"' . implode('"' . $sep . '"', $header) . '"' . "\n";
|
||||
foreach ($journal_data as $element_id => $element) {
|
||||
foreach ($element['blocks'] as $lines) {
|
||||
foreach ($lines as $line) {
|
||||
$out .= '"' . implode('"' . $sep . '"', $line) . '"' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get accounting account infos
|
||||
*
|
||||
* @param string $account Accounting account number
|
||||
* @return array Accounting account infos
|
||||
*/
|
||||
public function getAccountingAccountInfos($account)
|
||||
{
|
||||
if (!isset(self::$accounting_account_cached[$account])) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
||||
$accountingaccount = new AccountingAccount($this->db);
|
||||
$result = $accountingaccount->fetch(null, $account, true);
|
||||
if ($result > 0) {
|
||||
self::$accounting_account_cached[$account] = array(
|
||||
'found' => true,
|
||||
'label' => $accountingaccount->label,
|
||||
'code_formatted_1' => length_accounta(html_entity_decode($account)),
|
||||
'label_formatted_1' => utf8_decode(dol_trunc($accountingaccount->label, 32)),
|
||||
'label_formatted_2' => dol_trunc($accountingaccount->label, 32),
|
||||
);
|
||||
} else {
|
||||
self::$accounting_account_cached[$account] = array(
|
||||
'found' => false,
|
||||
'label' => '',
|
||||
'code_formatted_1' => length_accounta(html_entity_decode($account)),
|
||||
'label_formatted_1' => '',
|
||||
'label_formatted_2' => '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return self::$accounting_account_cached[$account];
|
||||
}
|
||||
}
|
||||
|
||||
313
htdocs/accountancy/journal/variousjournal.php
Normal file
313
htdocs/accountancy/journal/variousjournal.php
Normal file
@ -0,0 +1,313 @@
|
||||
<?php
|
||||
/* Copyright (C) 2021-2022 Open-DSI <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/journal/variousjournal.php
|
||||
* \ingroup Accountancy (Double entries)
|
||||
* \brief Page of a journal
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("banks", "accountancy", "compta", "other", "errors"));
|
||||
|
||||
$id_journal = GETPOST('id_journal', 'int');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
$date_startmonth = GETPOST('date_startmonth');
|
||||
$date_startday = GETPOST('date_startday');
|
||||
$date_startyear = GETPOST('date_startyear');
|
||||
$date_endmonth = GETPOST('date_endmonth');
|
||||
$date_endday = GETPOST('date_endday');
|
||||
$date_endyear = GETPOST('date_endyear');
|
||||
$in_bookkeeping = GETPOST('in_bookkeeping');
|
||||
if ($in_bookkeeping == '') {
|
||||
$in_bookkeeping = 'notyet';
|
||||
}
|
||||
|
||||
// Security check
|
||||
if (empty($conf->accounting->enabled)) {
|
||||
accessforbidden();
|
||||
}
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
}
|
||||
if (empty($user->rights->accounting->mouvements->lire)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Get information of journal
|
||||
$object = new AccountingJournal($db);
|
||||
$result = $object->fetch($id_journal);
|
||||
if ($result > 0) {
|
||||
$id_journal = $object->id;
|
||||
} elseif ($result < 0) {
|
||||
dol_print_error('', $object->error, $object->errors);
|
||||
} elseif ($result == 0) {
|
||||
accessforbidden($langs->trans('ErrorRecordNotFound'));
|
||||
}
|
||||
|
||||
$hookmanager->initHooks(array('globaljournal', $object->nature_text . 'journal'));
|
||||
$parameters = array();
|
||||
|
||||
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
|
||||
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
|
||||
|
||||
if (empty($date_startmonth) || empty($date_endmonth)) {
|
||||
// Period by default on transfer
|
||||
$dates = getDefaultDatesForTransfer();
|
||||
$date_start = $dates['date_start'];
|
||||
$date_end = $dates['date_end'];
|
||||
$pastmonthyear = $dates['pastmonthyear'];
|
||||
$pastmonth = $dates['pastmonth'];
|
||||
}
|
||||
|
||||
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) { // We define date_start and date_end, only if we did not submit the form
|
||||
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
|
||||
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
|
||||
}
|
||||
|
||||
$data_type = 'view';
|
||||
if ($action == 'writebookkeeping') $data_type = 'bookkeeping';
|
||||
if ($action == 'exportcsv') $data_type = 'csv';
|
||||
$journal_data = $object->getData($user, $data_type, $date_start, $date_end, $in_bookkeeping);
|
||||
if (!is_array($journal_data)) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
$reload = false;
|
||||
|
||||
// Bookkeeping Write
|
||||
if ($action == 'writebookkeeping') {
|
||||
$error = 0;
|
||||
|
||||
$result = $object->writeIntoBookkeeping($user, $journal_data);
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$error = abs($result);
|
||||
}
|
||||
|
||||
$nb_elements = count($journal_data);
|
||||
if (empty($error) && $nb_elements > 0) {
|
||||
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
||||
} elseif ($nb_elements == $error) {
|
||||
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
|
||||
} else {
|
||||
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
|
||||
}
|
||||
|
||||
$reload = true;
|
||||
} elseif ($action == 'exportcsv') {
|
||||
// Export CSV
|
||||
$result = $object->exportCsv($journal_data, $date_end);
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$reload = true;
|
||||
} else {
|
||||
$filename = 'journal';
|
||||
$type_export = 'journal';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
||||
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
print $result;
|
||||
|
||||
$db->close();
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
// Must reload data, so we make a redirect
|
||||
if ($reload) {
|
||||
$param = 'id_journal=' . $id_journal;
|
||||
$param .= '&date_startday=' . $date_startday;
|
||||
$param .= '&date_startmonth=' . $date_startmonth;
|
||||
$param .= '&date_startyear=' . $date_startyear;
|
||||
$param .= '&date_endday=' . $date_endday;
|
||||
$param .= '&date_endmonth=' . $date_endmonth;
|
||||
$param .= '&date_endyear=' . $date_endyear;
|
||||
$param .= '&in_bookkeeping=' . $in_bookkeeping;
|
||||
header("Location: " . $_SERVER['PHP_SELF'] . ($param ? '?' . $param : ''));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
if ($object->nature == 2) {
|
||||
$title = $langs->trans("SellsJournal");
|
||||
$some_mandatory_steps_of_setup_were_not_done = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "" || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1';
|
||||
$account_accounting_not_defined = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "" || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1';
|
||||
} elseif ($object->nature == 3) {
|
||||
$title = $langs->trans("PurchasesJournal");
|
||||
$some_mandatory_steps_of_setup_were_not_done = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "" || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1';
|
||||
$account_accounting_not_defined = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "" || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1';
|
||||
} elseif ($object->nature == 4) {
|
||||
$title = $langs->trans("FinanceJournal");
|
||||
$some_mandatory_steps_of_setup_were_not_done = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "" || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1'
|
||||
|| $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "" || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1'
|
||||
|| empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1';
|
||||
$account_accounting_not_defined = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "" || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1'
|
||||
|| $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "" || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1';
|
||||
} elseif ($object->nature == 5) {
|
||||
$title = $langs->trans("ExpenseReportsJournal");
|
||||
$some_mandatory_steps_of_setup_were_not_done = empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1';
|
||||
$account_accounting_not_defined = empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1';
|
||||
} else {
|
||||
$title = $object->getLibType();
|
||||
$some_mandatory_steps_of_setup_were_not_done = false;
|
||||
$account_accounting_not_defined = false;
|
||||
}
|
||||
|
||||
|
||||
$nom = $title . ' | ' . $object->getNomUrl(0, 1, 1, '', 1);
|
||||
$nomlink = '';
|
||||
$periodlink = '';
|
||||
$exportlink = '';
|
||||
$builddate = dol_now();
|
||||
$description = $langs->trans("DescJournalOnlyBindedVisible") . '<br>';
|
||||
if ($object->nature == 2 || $object->nature == 3) {
|
||||
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$description .= $langs->trans("DepositsAreNotIncluded");
|
||||
} else {
|
||||
$description .= $langs->trans("DepositsAreIncluded");
|
||||
}
|
||||
}
|
||||
|
||||
$listofchoices = array('notyet' => $langs->trans("NotYetInGeneralLedger"), 'already' => $langs->trans("AlreadyInGeneralLedger"));
|
||||
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
|
||||
$period .= ' - ' . $langs->trans("JournalizationInLedgerStatus") . ' ' . $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
|
||||
$varlink = 'id_journal=' . $id_journal;
|
||||
|
||||
llxHeader('', $title);
|
||||
|
||||
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
|
||||
|
||||
if ($object->nature == 4) { // Bank journal
|
||||
// Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed)
|
||||
$sql = "SELECT COUNT(rowid) as nb";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "bank_account";
|
||||
$sql .= " WHERE entity = " . (int) $conf->entity;
|
||||
$sql .= " AND fk_accountancy_journal IS NULL";
|
||||
$sql .= " AND clos=0";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj->nb > 0) {
|
||||
print '<br>' . img_warning() . ' ' . $langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount");
|
||||
print ' : ' . $langs->trans("AccountancyAreaDescBank", 9, '<strong>' . $langs->transnoentitiesnoconv("MenuAccountancy") . '-' . $langs->transnoentitiesnoconv("Setup") . "-" . $langs->transnoentitiesnoconv("BankAccounts") . '</strong>');
|
||||
}
|
||||
} else dol_print_error($db);
|
||||
}
|
||||
|
||||
// Button to write into Ledger
|
||||
if ($some_mandatory_steps_of_setup_were_not_done) {
|
||||
print '<br><div class="warning">' . img_warning() . ' ' . $langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
|
||||
print ' : ' . $langs->trans("AccountancyAreaDescMisc", 4, '<strong>' . $langs->transnoentitiesnoconv("MenuAccountancy") . '-' . $langs->transnoentitiesnoconv("Setup") . "-" . $langs->transnoentitiesnoconv("MenuDefaultAccounts") . '</strong>');
|
||||
print '</div>';
|
||||
}
|
||||
print '<div class="tabsAction tabsActionNoBottom">';
|
||||
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') {
|
||||
print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
|
||||
}
|
||||
if ($account_accounting_not_defined) {
|
||||
print '<input type="button" class="butActionRefused classfortooltip" title="' . dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")) . '" value="' . $langs->trans("WriteBookKeeping") . '" />';
|
||||
} else {
|
||||
if ($in_bookkeeping == 'notyet') {
|
||||
print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
} else {
|
||||
print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">' . $langs->trans("WriteBookKeeping") . '</a>';
|
||||
}
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
// TODO Avoid using js. We can use a direct link with $param
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
function launch_export() {
|
||||
$("div.fiche form input[name=\"action\"]").val("exportcsv");
|
||||
$("div.fiche form input[type=\"submit\"]").click();
|
||||
$("div.fiche form input[name=\"action\"]").val("");
|
||||
}
|
||||
function writebookkeeping() {
|
||||
console.log("click on writebookkeeping");
|
||||
$("div.fiche form input[name=\"action\"]").val("writebookkeeping");
|
||||
$("div.fiche form input[type=\"submit\"]").click();
|
||||
$("div.fiche form input[name=\"action\"]").val("");
|
||||
}
|
||||
</script>';
|
||||
|
||||
$object_label = $langs->trans("ObjectsRef");
|
||||
if ($object->nature == 2 || $object->nature == 3) $object_label = $langs->trans("InvoiceRef");
|
||||
if ($object->nature == 5) $object_label = $langs->trans("ExpenseReportRef");
|
||||
|
||||
/*
|
||||
* Show result array
|
||||
*/
|
||||
print '<br>';
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>' . $langs->trans("Date") . '</td>';
|
||||
print '<td>' . $langs->trans("Piece") . ' (' . $object_label . ')</td>';
|
||||
print '<td>' . $langs->trans("AccountAccounting") . '</td>';
|
||||
print '<td>' . $langs->trans("SubledgerAccount") . '</td>';
|
||||
print '<td>' . $langs->trans("LabelOperation") . '</td>';
|
||||
if ($object->nature == 4) print '<td class="center">' . $langs->trans("PaymentMode") . '</td>'; // bank
|
||||
print '<td class="right">' . $langs->trans("Debit") . '</td>';
|
||||
print '<td class="right">' . $langs->trans("Credit") . '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ($journal_data as $element_id => $element) {
|
||||
foreach ($element['blocks'] as $lines) {
|
||||
foreach ($lines as $line) {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>' . $line['date'] . '</td>';
|
||||
print '<td>' . $line['piece'] . '</td>';
|
||||
print '<td>' . $line['account_accounting'] . '</td>';
|
||||
print '<td>' . $line['subledger_account'] . '</td>';
|
||||
print '<td>' . $line['label_operation'] . '</td>';
|
||||
if ($object->nature == 4) print '<td class="center">' . $line['payment_mode'] . '</td>';
|
||||
print '<td class="right nowraponall">' . $line['debit'] . '</td>';
|
||||
print '<td class="right nowraponall">' . $line['credit'] . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
@ -659,8 +659,7 @@ class Adherent extends CommonObject
|
||||
$nbrowsaffected = 0;
|
||||
$error = 0;
|
||||
|
||||
dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass." nosyncthirdparty=".$nosyncthirdparty.", email=".
|
||||
$this->email);
|
||||
dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass." nosyncthirdparty=".$nosyncthirdparty.", email=".$this->email);
|
||||
|
||||
// Clean parameters
|
||||
$this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
|
||||
@ -693,7 +692,9 @@ class Adherent extends CommonObject
|
||||
$sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman'
|
||||
$sql .= ", login = ".($this->login ? "'".$this->db->escape($this->login)."'" : "null");
|
||||
$sql .= ", societe = ".($this->company ? "'".$this->db->escape($this->company)."'" : ($this->societe ? "'".$this->db->escape($this->societe)."'" : "null"));
|
||||
$sql .= ", fk_soc = ".($this->socid > 0 ? $this->db->escape($this->socid) : "null");
|
||||
if ($this->socid) {
|
||||
$sql .= ", fk_soc = ".($this->socid > 0 ? $this->db->escape($this->socid) : "null"); // Must be modified only when creating from a third-party
|
||||
}
|
||||
$sql .= ", address = ".($this->address ? "'".$this->db->escape($this->address)."'" : "null");
|
||||
$sql .= ", zip = ".($this->zip ? "'".$this->db->escape($this->zip)."'" : "null");
|
||||
$sql .= ", town = ".($this->town ? "'".$this->db->escape($this->town)."'" : "null");
|
||||
@ -713,9 +714,6 @@ class Adherent extends CommonObject
|
||||
$sql .= ", fk_adherent_type = ".$this->db->escape($this->typeid);
|
||||
$sql .= ", morphy = '".$this->db->escape($this->morphy)."'";
|
||||
$sql .= ", birth = ".($this->birth ? "'".$this->db->idate($this->birth)."'" : "null");
|
||||
if ($this->socid) {
|
||||
$sql .= ", fk_soc = '".$this->db->escape($this->socid)."'"; // Must be modified only when creating from a third-party
|
||||
}
|
||||
if ($this->datefin) {
|
||||
$sql .= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription
|
||||
}
|
||||
|
||||
@ -307,7 +307,7 @@ $memberstatic = new Adherent($db);
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
if (!empty($search_categ) || !empty($catid)) {
|
||||
if ((!empty($search_categ) && $search_categ > 0) || !empty($catid)) {
|
||||
$sql = "SELECT DISTINCT";
|
||||
} else {
|
||||
$sql = "SELECT";
|
||||
@ -336,7 +336,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
|
||||
if (!empty($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)";
|
||||
}
|
||||
if (!empty($search_categ) || !empty($catid)) {
|
||||
if ((!empty($search_categ) && $search_categ > 0) || !empty($catid)) {
|
||||
// We need this table joined to the select in order to filter by categ
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member";
|
||||
}
|
||||
@ -540,7 +540,7 @@ if ($search_login) {
|
||||
if ($search_email) {
|
||||
$param .= "&search_email=".urlencode($search_email);
|
||||
}
|
||||
if ($search_categ) {
|
||||
if ($search_categ > 0 || $search_categ == -2) {
|
||||
$param .= "&search_categ=".urlencode($search_categ);
|
||||
}
|
||||
if ($search_company) {
|
||||
@ -573,7 +573,7 @@ if ($search_phone_mobile != '') {
|
||||
if ($search_filter && $search_filter != '-1') {
|
||||
$param .= "&search_filter=".urlencode($search_filter);
|
||||
}
|
||||
if ($search_status != "" && $search_status != Adherent::STATUS_DRAFT) {
|
||||
if ($search_status != "" && $search_status != -3) {
|
||||
$param .= "&search_status=".urlencode($search_status);
|
||||
}
|
||||
if ($search_type > 0) {
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
|
||||
* Copyright (C) 2020-2022 Open-Dsi <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -100,7 +100,7 @@ $hookmanager->initHooks(array('admin'));
|
||||
// Put here declaration of dictionaries properties
|
||||
|
||||
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
|
||||
$taborder = array(9, 15, 30, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 6, 24, 0, 29, 0, 33, 34, 32, 28, 17, 35, 36, 0, 10, 23, 12, 13, 7, 0, 14, 0, 22, 20, 18, 21, 41, 0, 37, 42, 0, 43, 0, 25, 0);
|
||||
$taborder = array(9, 15, 30, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 6, 24, 0, 29, 0, 33, 34, 32, 28, 17, 35, 36, 0, 10, 23, 12, 13, 7, 0, 14, 0, 22, 20, 18, 21, 41, 0, 37, 42, 0, 43, 0, 25, 0, 44, 0);
|
||||
|
||||
// Name of SQL tables of dictionaries
|
||||
$tabname = array();
|
||||
@ -147,6 +147,7 @@ $tabname[40] = MAIN_DB_PREFIX."c_stcommcontact";
|
||||
$tabname[41] = MAIN_DB_PREFIX."c_transport_mode";
|
||||
$tabname[42] = MAIN_DB_PREFIX."c_product_nature";
|
||||
$tabname[43] = MAIN_DB_PREFIX."c_productbatch_qcstatus";
|
||||
$tabname[44] = MAIN_DB_PREFIX."c_asset_disposal_type";
|
||||
|
||||
// Dictionary labels
|
||||
$tablib = array();
|
||||
@ -193,6 +194,7 @@ $tablib[40] = "DictionaryProspectContactStatus";
|
||||
$tablib[41] = "DictionaryTransportMode";
|
||||
$tablib[42] = "DictionaryProductNature";
|
||||
$tablib[43] = "DictionaryBatchStatus";
|
||||
$tablib[44] = "DictionaryAssetDisposalType";
|
||||
|
||||
// Requests to extract data
|
||||
$tabsql = array();
|
||||
@ -239,6 +241,7 @@ $tabsql[40] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN
|
||||
$tabsql[41] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_transport_mode";
|
||||
$tabsql[42] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_product_nature";
|
||||
$tabsql[43] = "SELECT rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_productbatch_qcstatus";
|
||||
$tabsql[44] = "SELECT rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_asset_disposal_type";
|
||||
|
||||
// Criteria to sort dictionaries
|
||||
$tabsqlsort = array();
|
||||
@ -285,6 +288,7 @@ $tabsqlsort[40] = "code ASC";
|
||||
$tabsqlsort[41] = "code ASC";
|
||||
$tabsqlsort[42] = "code ASC";
|
||||
$tabsqlsort[43] = "code ASC";
|
||||
$tabsqlsort[44] = "code ASC";
|
||||
|
||||
// Field names in select result for dictionary display
|
||||
$tabfield = array();
|
||||
@ -331,6 +335,7 @@ $tabfield[40] = "code,libelle,picto";
|
||||
$tabfield[41] = "code,label";
|
||||
$tabfield[42] = "code,label";
|
||||
$tabfield[43] = "code,label";
|
||||
$tabfield[44] = "code,label";
|
||||
|
||||
// Edit field names for editing a record
|
||||
$tabfieldvalue = array();
|
||||
@ -377,6 +382,7 @@ $tabfieldvalue[40] = "code,libelle,picto";
|
||||
$tabfieldvalue[41] = "code,label";
|
||||
$tabfieldvalue[42] = "code,label";
|
||||
$tabfieldvalue[43] = "code,label";
|
||||
$tabfieldvalue[44] = "code,label";
|
||||
|
||||
// Field names in the table for inserting a record
|
||||
$tabfieldinsert = array();
|
||||
@ -424,6 +430,7 @@ $tabfieldinsert[40] = "code,libelle,picto";
|
||||
$tabfieldinsert[41] = "code,label";
|
||||
$tabfieldinsert[42] = "code,label";
|
||||
$tabfieldinsert[43] = "code,label";
|
||||
$tabfieldinsert[44] = "code,label";
|
||||
|
||||
// Rowid name of field depending if field is autoincrement on or off..
|
||||
// Use "" if id field is "rowid" and has autoincrement on
|
||||
@ -472,6 +479,7 @@ $tabrowid[40] = "id";
|
||||
$tabrowid[41] = "";
|
||||
$tabrowid[42] = "rowid";
|
||||
$tabrowid[43] = "rowid";
|
||||
$tabrowid[44] = "rowid";
|
||||
|
||||
// Condition to show dictionary in setup page
|
||||
$tabcond = array();
|
||||
@ -518,6 +526,7 @@ $tabcond[40] = (!empty($conf->societe->enabled) && !empty($conf->global->THIRDPA
|
||||
$tabcond[41] = !empty($conf->intracommreport->enabled);
|
||||
$tabcond[42] = !empty($conf->product->enabled);
|
||||
$tabcond[43] = !empty($conf->product->enabled) && !empty($conf->productbatch->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2;
|
||||
$tabcond[44] = !empty($conf->asset->enabled);
|
||||
|
||||
// List of help for fields
|
||||
$tabhelp = array();
|
||||
@ -564,6 +573,7 @@ $tabhelp[40] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->tra
|
||||
$tabhelp[41] = array('code'=>$langs->trans("EnterAnyCode"));
|
||||
$tabhelp[42] = array('code'=>$langs->trans("EnterAnyCode"));
|
||||
$tabhelp[43] = array('code'=>$langs->trans("EnterAnyCode"));
|
||||
$tabhelp[44] = array('code'=>$langs->trans("EnterAnyCode"));
|
||||
|
||||
// Table to store complete informations (will replace all other table). Key is table name.
|
||||
$tabcomplete = array(
|
||||
@ -609,6 +619,7 @@ $tabcomplete = array(
|
||||
'c_stcommcontact'=>array('picto'=>'company'),
|
||||
'c_product_nature'=>array('picto'=>'product'),
|
||||
'c_productbatch_qcstatus'=>array('picto'=>'lot'),
|
||||
'c_asset_disposal_type'=>array('picto'=>'asset'),
|
||||
|
||||
);
|
||||
|
||||
|
||||
189
htdocs/asset/accountancy_codes.php
Normal file
189
htdocs/asset/accountancy_codes.php
Normal file
@ -0,0 +1,189 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/accountancy_code.php
|
||||
* \ingroup asset
|
||||
* \brief Card with accountancy code on Asset
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetaccountancycodes.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("assets", "companies"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new Asset($db);
|
||||
$assetaccountancycodes = new AssetAccountancyCodes($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->asset->dir_output . '/temp/massgeneration/' . $user->id;
|
||||
$hookmanager->initHooks(array('assetaccountancycodes', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
|
||||
}
|
||||
|
||||
$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php
|
||||
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
|
||||
$result = $assetaccountancycodes->fetchAccountancyCodes($object->id);
|
||||
if ($result < 0) {
|
||||
setEventMessages($assetaccountancycodes->error, $assetaccountancycodes->errors, 'errors');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
if (empty($reshook)) {
|
||||
$backurlforlist = DOL_URL_ROOT.'/asset/list.php';
|
||||
|
||||
if (empty($backtopage) || ($cancel && empty($id))) {
|
||||
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
|
||||
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
|
||||
$backtopage = $backurlforlist;
|
||||
} else {
|
||||
$backtopage = DOL_URL_ROOT.'/asset/accountancy_codes.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($cancel) {
|
||||
/*var_dump($cancel);var_dump($backtopage);var_dump($backtopageforcancel);exit;*/
|
||||
if (!empty($backtopageforcancel)) {
|
||||
header("Location: ".$backtopageforcancel);
|
||||
exit;
|
||||
} elseif (!empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
$action = '';
|
||||
}
|
||||
|
||||
if ($action == "update") {
|
||||
$assetaccountancycodes->setAccountancyCodesFromPost();
|
||||
|
||||
$result = $assetaccountancycodes->updateAccountancyCodes($user, $object->id);
|
||||
if ($result < 0) {
|
||||
setEventMessages($assetaccountancycodes->error, $assetaccountancycodes->errors, 'errors');
|
||||
$action = 'edit';
|
||||
} else {
|
||||
setEventMessage($langs->trans('RecordSaved'));
|
||||
header("Location: " . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$help_url = '';
|
||||
llxHeader('', $langs->trans('Asset'), $help_url);
|
||||
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$head = assetPrepareHead($object);
|
||||
print dol_get_fiche_head($head, 'accountancy_codes', $langs->trans("Asset"), -1, $object->picto);
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/asset/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '</div>';
|
||||
|
||||
if ($action == 'edit') {
|
||||
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '">';
|
||||
print '<input type="hidden" name="token" value="' . newToken() . '">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
if ($backtopage) {
|
||||
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
|
||||
}
|
||||
if ($backtopageforcancel) {
|
||||
print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
|
||||
}
|
||||
|
||||
print dol_get_fiche_head(array(), '');
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/asset/tpl/accountancy_codes_edit.tpl.php';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print $form->buttonsSaveCancel();
|
||||
|
||||
print '</form>';
|
||||
} else {
|
||||
include DOL_DOCUMENT_ROOT . '/asset/tpl/accountancy_codes_view.tpl.php';
|
||||
}
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
if ($action != 'edit') {
|
||||
print '<div class="tabsAction">' . "\n";
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
if ($object->status == $object::STATUS_DRAFT/* && !empty($object->enabled_modes)*/) {
|
||||
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit&token=' . newToken(), '', $permissiontoadd);
|
||||
}
|
||||
}
|
||||
print '</div>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -1,5 +1,11 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -13,20 +19,20 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/admin/assets_type_extrafields.php
|
||||
* \ingroup asset
|
||||
* \brief Page to setup extra fields type of assets
|
||||
* \file htdocs/asset/admin/asset_extrafields.php
|
||||
* \ingroup asset
|
||||
* \brief Page to setup extra fields of asset
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('assets', 'admin'));
|
||||
$langs->loadLangs(array("assets", "admin", "companies"));
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
$form = new Form($db);
|
||||
@ -40,7 +46,7 @@ foreach ($tmptype2label as $key => $val) {
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$attrname = GETPOST('attrname', 'alpha');
|
||||
$elementtype = 'adherent_type'; //Must be the $table_element of the class that manage extrafield
|
||||
$elementtype = 'asset'; //Must be the $table_element of the class that manage extrafield
|
||||
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
@ -59,38 +65,47 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
|
||||
* View
|
||||
*/
|
||||
|
||||
$textobject = $langs->transnoentitiesnoconv("AssetsTypes");
|
||||
$help_url = '';
|
||||
$page_name = "AssetSetup";
|
||||
$textobject = $langs->transnoentitiesnoconv("Assets");
|
||||
|
||||
llxHeader('', $langs->trans("AssetsSetup"));
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup');
|
||||
llxHeader('', $langs->trans("AssetSetup"), $help_url);
|
||||
|
||||
|
||||
$head = asset_admin_prepare_head();
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
|
||||
|
||||
print dol_get_fiche_head($head, 'attributes_type', $langs->trans("Assets"), -1, 'generic');
|
||||
|
||||
$head = assetAdminPrepareHead();
|
||||
|
||||
print dol_get_fiche_head($head, 'asset_extrafields', $langs->trans($page_name), -1, 'asset');
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
|
||||
// Buttons
|
||||
if ($action != 'create' && $action != 'edit') {
|
||||
print '<div class="tabsAction">';
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute").'</a></div>';
|
||||
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
// Creation of an optional field
|
||||
|
||||
/*
|
||||
* Creation of an optional field
|
||||
*/
|
||||
if ($action == 'create') {
|
||||
print "<br>";
|
||||
print '<br><div id="newattrib"></div>';
|
||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
|
||||
}
|
||||
|
||||
// Edition of an optional field
|
||||
/*
|
||||
* Edition of an optional field
|
||||
*/
|
||||
if ($action == 'edit' && !empty($attrname)) {
|
||||
print "<br>";
|
||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||
@ -1,6 +1,11 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -17,9 +22,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/admin/assets_extrafields.php
|
||||
* \file htdocs/asset/admin/assetmodel_extrafields.php
|
||||
* \ingroup asset
|
||||
* \brief Page to setup extra fields of assets
|
||||
* \brief Page to setup extra fields of asset model
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
@ -41,7 +46,7 @@ foreach ($tmptype2label as $key => $val) {
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$attrname = GETPOST('attrname', 'alpha');
|
||||
$elementtype = 'don'; //Must be the $table_element of the class that manage extrafield
|
||||
$elementtype = 'asset_model'; //Must be the $table_element of the class that manage extrafield
|
||||
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
@ -60,17 +65,20 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
|
||||
* View
|
||||
*/
|
||||
|
||||
$textobject = $langs->transnoentitiesnoconv("Assets");
|
||||
$help_url = '';
|
||||
$page_name = "AssetSetup";
|
||||
$textobject = $langs->transnoentitiesnoconv("AssetModels");
|
||||
|
||||
llxHeader('', $langs->trans("AssetsSetup"));
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup');
|
||||
llxHeader('', $langs->trans("AssetSetup"), $help_url);
|
||||
|
||||
|
||||
$head = asset_admin_prepare_head();
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
|
||||
|
||||
print dol_get_fiche_head($head, 'attributes', $langs->trans("Assets"), -1, 'generic');
|
||||
|
||||
$head = assetAdminPrepareHead();
|
||||
|
||||
print dol_get_fiche_head($head, 'assetmodel_extrafields', $langs->trans($page_name), -1, 'asset');
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
|
||||
|
||||
@ -80,29 +88,24 @@ print dol_get_fiche_end();
|
||||
// Buttons
|
||||
if ($action != 'create' && $action != 'edit') {
|
||||
print '<div class="tabsAction">';
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a></div>';
|
||||
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Create optional field */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
/*
|
||||
* Creation of an optional field
|
||||
*/
|
||||
if ($action == 'create') {
|
||||
print "<br>";
|
||||
print '<br><div id="newattrib"></div>';
|
||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Edit optional field */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
/*
|
||||
* Edition of an optional field
|
||||
*/
|
||||
if ($action == 'edit' && !empty($attrname)) {
|
||||
print "<br>";
|
||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||
@ -18,8 +18,8 @@
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/admin/setup.php
|
||||
* \ingroup assets
|
||||
* \brief Assets setup page.
|
||||
* \ingroup asset
|
||||
* \brief Asset setup page.
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
@ -40,30 +40,421 @@ if (!$user->admin) {
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
$arrayofparameters = array('FIXEDASSETS_MYPARAM1'=>array('css'=>'minwidth200'), 'FIXEDASSETS_MYPARAM2'=>array('css'=>'minwidth500'));
|
||||
$value = GETPOST('value', 'alpha');
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$scandir = GETPOST('scan_dir', 'alpha');
|
||||
$type = 'asset';
|
||||
|
||||
$arrayofparameters = array(
|
||||
'ASSET_ACCOUNTANCY_CATEGORY'=>array('type'=>'accountancy_category', 'enabled'=>1),
|
||||
'ASSET_DEPRECIATION_DURATION_PER_YEAR'=>array('type'=>'string', 'css'=>'minwidth200', 'enabled'=>1),
|
||||
//'ASSET_MYPARAM2'=>array('type'=>'textarea','enabled'=>1),
|
||||
//'ASSET_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
|
||||
//'ASSET_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1),
|
||||
//'ASSET_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1),
|
||||
//'ASSET_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1),
|
||||
//'ASSET_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1),
|
||||
//'ASSET_MYPARAM7'=>array('type'=>'product', 'enabled'=>1),
|
||||
);
|
||||
|
||||
$error = 0;
|
||||
$setupnotempty = 0;
|
||||
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
if ((float) DOL_VERSION >= 6) {
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
}
|
||||
|
||||
if ($action == 'updateMask') {
|
||||
$maskconstorder = GETPOST('maskconstorder', 'alpha');
|
||||
$maskorder = GETPOST('maskorder', 'alpha');
|
||||
|
||||
if ($maskconstorder) {
|
||||
$res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
} elseif ($action == 'specimen') {
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/asset/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filefound) {
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} elseif ($action == 'setmod') {
|
||||
// TODO Check if numbering module chosen can be activated by calling method canBeActivated
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
if (!empty($tmpobjectkey)) {
|
||||
$constforval = 'ASSET_'.strtoupper($tmpobjectkey)."_ADDON";
|
||||
dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
} elseif ($action == 'set') {
|
||||
// Activate a model
|
||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||
} elseif ($action == 'del') {
|
||||
$ret = delDocumentModel($value, $type);
|
||||
if ($ret > 0) {
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
if (!empty($tmpobjectkey)) {
|
||||
$constforval = 'ASSET_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
|
||||
if ($conf->global->$constforval == "$value") {
|
||||
dolibarr_del_const($db, $constforval, $conf->entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'setdoc') {
|
||||
// Set or unset default model
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
if (!empty($tmpobjectkey)) {
|
||||
$constforval = 'ASSET_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
|
||||
if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
|
||||
// The constant that was read before the new set
|
||||
// We therefore requires a variable to have a coherent view
|
||||
$conf->global->$constforval = $value;
|
||||
}
|
||||
|
||||
// We disable/enable the document template (into llx_document_model table)
|
||||
$ret = delDocumentModel($value, $type);
|
||||
if ($ret > 0) {
|
||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'unsetdoc') {
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
if (!empty($tmpobjectkey)) {
|
||||
$constforval = 'ASSET_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
|
||||
dolibarr_del_const($db, $constforval, $conf->entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader('', $langs->trans("AssetsSetup"));
|
||||
$form = new Form($db);
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup');
|
||||
$help_url = '';
|
||||
$page_name = "AssetSetup";
|
||||
|
||||
llxHeader('', $langs->trans($page_name), $help_url);
|
||||
|
||||
// Subheader
|
||||
$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
|
||||
|
||||
print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
|
||||
|
||||
// Configuration header
|
||||
$head = assetAdminPrepareHead();
|
||||
print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "asset");
|
||||
|
||||
// Setup page goes here
|
||||
echo '<span class="opacitymedium">'.$langs->trans("AssetSetupPage").'</span>';
|
||||
|
||||
|
||||
$head = asset_admin_prepare_head();
|
||||
$moduledir = 'asset';
|
||||
$myTmpObjects = array();
|
||||
$myTmpObjects['Asset'] = array('includerefgeneration'=>1, 'includedocgeneration'=>0);
|
||||
|
||||
print dol_get_fiche_head($head, 'settings', $langs->trans("Assets"), -1, 'generic');
|
||||
|
||||
foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
if ($myTmpObjectKey == 'MyObject') {
|
||||
continue;
|
||||
}
|
||||
if ($myTmpObjectArray['includerefgeneration']) {
|
||||
/*
|
||||
* Orders Numbering model
|
||||
*/
|
||||
$setupnotempty++;
|
||||
|
||||
print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Name").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td class="nowrap">'.$langs->trans("Example").'</td>';
|
||||
print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
|
||||
print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
clearstatcache();
|
||||
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$dir = dol_buildpath($reldir."core/modules/".$moduledir);
|
||||
|
||||
if (is_dir($dir)) {
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle)) {
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
|
||||
require_once $dir.'/'.$file.'.php';
|
||||
|
||||
$module = new $file($db);
|
||||
|
||||
// Show modules according to features level
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||
continue;
|
||||
}
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($module->isEnabled()) {
|
||||
dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
|
||||
|
||||
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
|
||||
print $module->info();
|
||||
print '</td>';
|
||||
|
||||
// Show example of numbering model
|
||||
print '<td class="nowrap">';
|
||||
$tmp = $module->getExample();
|
||||
if (preg_match('/^Error/', $tmp)) {
|
||||
$langs->load("errors");
|
||||
print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||
} elseif ($tmp == 'NotConfigured') {
|
||||
print $langs->trans($tmp);
|
||||
} else {
|
||||
print $tmp;
|
||||
}
|
||||
print '</td>'."\n";
|
||||
|
||||
print '<td class="center">';
|
||||
$constforvar = 'ASSET_'.strtoupper($myTmpObjectKey).'_ADDON';
|
||||
if ($conf->global->$constforvar == $file) {
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
} else {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
$mytmpinstance = new $myTmpObjectKey($db);
|
||||
$mytmpinstance->initAsSpecimen();
|
||||
|
||||
// Info
|
||||
$htmltooltip = '';
|
||||
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
|
||||
$nextval = $module->getNextValue($mytmpinstance);
|
||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
||||
if ($nextval) {
|
||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
|
||||
$nextval = $langs->trans($nextval);
|
||||
}
|
||||
$htmltooltip .= $nextval.'<br>';
|
||||
} else {
|
||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
print '<td class="center">';
|
||||
print $form->textwithpicto('', $htmltooltip, 1, 0);
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
print "</table><br>\n";
|
||||
}
|
||||
|
||||
if ($myTmpObjectArray['includedocgeneration']) {
|
||||
/*
|
||||
* Document templates generators
|
||||
*/
|
||||
$setupnotempty++;
|
||||
$type = strtolower($myTmpObjectKey);
|
||||
|
||||
print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
|
||||
|
||||
// Load array def with activated templates
|
||||
$def = array();
|
||||
$sql = "SELECT nom";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = '".$db->escape($type)."'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num_rows = $db->num_rows($resql);
|
||||
while ($i < $num_rows) {
|
||||
$array = $db->fetch_array($resql);
|
||||
array_push($def, $array[0]);
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print "<table class=\"noborder\" width=\"100%\">\n";
|
||||
print "<tr class=\"liste_titre\">\n";
|
||||
print '<td>'.$langs->trans("Name").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
|
||||
print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
|
||||
print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
|
||||
print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
clearstatcache();
|
||||
|
||||
foreach ($dirmodels as $reldir) {
|
||||
foreach (array('', '/doc') as $valdir) {
|
||||
$realpath = $reldir."core/modules/".$moduledir.$valdir;
|
||||
$dir = dol_buildpath($realpath);
|
||||
|
||||
if (is_dir($dir)) {
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle)) {
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
$filelist[] = $file;
|
||||
}
|
||||
closedir($handle);
|
||||
arsort($filelist);
|
||||
|
||||
foreach ($filelist as $file) {
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
|
||||
if (file_exists($dir.'/'.$file)) {
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db);
|
||||
|
||||
$modulequalified = 1;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||
$modulequalified = 0;
|
||||
}
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||
$modulequalified = 0;
|
||||
}
|
||||
|
||||
if ($modulequalified) {
|
||||
print '<tr class="oddeven"><td width="100">';
|
||||
print (empty($module->name) ? $name : $module->name);
|
||||
print "</td><td>\n";
|
||||
if (method_exists($module, 'info')) {
|
||||
print $module->info($langs);
|
||||
} else {
|
||||
print $module->description;
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Active
|
||||
if (in_array($name, $def)) {
|
||||
print '<td class="center">'."\n";
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
|
||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td class="center">'."\n";
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
|
||||
print "</td>";
|
||||
}
|
||||
|
||||
// Default
|
||||
print '<td class="center">';
|
||||
$constforvar = 'ASSET_'.strtoupper($myTmpObjectKey).'_ADDON';
|
||||
if ($conf->global->$constforvar == $name) {
|
||||
//print img_picto($langs->trans("Default"), 'on');
|
||||
// Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&token='.newToken().'&object='.urlencode(strtolower($myTmpObjectKey)).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
|
||||
} else {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&object='.urlencode(strtolower($myTmpObjectKey)).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||
if ($module->type == 'pdf') {
|
||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
}
|
||||
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
|
||||
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
|
||||
|
||||
print '<td class="center">';
|
||||
print $form->textwithpicto('', $htmltooltip, 1, 0);
|
||||
print '</td>';
|
||||
|
||||
// Preview
|
||||
print '<td class="center">';
|
||||
if ($module->type == 'pdf') {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
|
||||
} else {
|
||||
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'edit') {
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
@ -73,37 +464,221 @@ if ($action == 'edit') {
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
foreach ($arrayofparameters as $key => $val) {
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
|
||||
print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'"></td></tr>';
|
||||
}
|
||||
foreach ($arrayofparameters as $constname => $val) {
|
||||
if ($val['enabled']==1) {
|
||||
$setupnotempty++;
|
||||
print '<tr class="oddeven"><td>';
|
||||
$tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
|
||||
print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
|
||||
print '</td><td>';
|
||||
|
||||
if ($val['type'] == 'textarea') {
|
||||
print '<textarea class="flat" name="'.$constname.'" id="'.$constname.'" cols="50" rows="5" wrap="soft">' . "\n";
|
||||
print $conf->global->{$constname};
|
||||
print "</textarea>\n";
|
||||
} elseif ($val['type']== 'html') {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
|
||||
$doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
|
||||
$doleditor->Create();
|
||||
} elseif ($val['type'] == 'yesno') {
|
||||
print $form->selectyesno($constname, $conf->global->{$constname}, 1);
|
||||
} elseif (preg_match('/emailtemplate:/', $val['type'])) {
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
|
||||
$tmp = explode(':', $val['type']);
|
||||
$nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
|
||||
//$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
|
||||
$arrayofmessagename = array();
|
||||
if (is_array($formmail->lines_model)) {
|
||||
foreach ($formmail->lines_model as $modelmail) {
|
||||
//var_dump($modelmail);
|
||||
$moreonlabel = '';
|
||||
if (!empty($arrayofmessagename[$modelmail->label])) {
|
||||
$moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
|
||||
}
|
||||
// The 'label' is the key that is unique if we exclude the language
|
||||
$arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel;
|
||||
}
|
||||
}
|
||||
print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
|
||||
} elseif (preg_match('/category:/', $val['type'])) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
$formother = new FormOther($db);
|
||||
|
||||
$tmp = explode(':', $val['type']);
|
||||
print img_picto('', 'category', 'class="pictofixedwidth"');
|
||||
print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
|
||||
} elseif (preg_match('/thirdparty_type/', $val['type'])) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
$formcompany = new FormCompany($db);
|
||||
print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname);
|
||||
} elseif ($val['type'] == 'securekey') {
|
||||
print '<input required="required" type="text" class="flat" id="'.$constname.'" name="'.$constname.'" value="'.(GETPOST($constname, 'alpha') ?GETPOST($constname, 'alpha') : $conf->global->{$constname}).'" size="40">';
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"');
|
||||
}
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
print "\n".'<script type="text/javascript">';
|
||||
print '$(document).ready(function () {
|
||||
$("#generate_token'.$constname.'").click(function() {
|
||||
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
|
||||
action: \'getrandompassword\',
|
||||
generic: true
|
||||
},
|
||||
function(token) {
|
||||
$("#'.$constname.'").val(token);
|
||||
});
|
||||
});
|
||||
});';
|
||||
print '</script>';
|
||||
}
|
||||
} elseif ($val['type'] == 'product') {
|
||||
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
|
||||
$selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
|
||||
$form->select_produits($selected, $constname, '', 0);
|
||||
}
|
||||
} elseif ($val['type'] == 'accountancy_code') {
|
||||
$selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
|
||||
$formaccounting = new FormAccounting($db);
|
||||
print $formaccounting->select_account($selected, $constname, 1, null, 1, 1, 'minwidth150 maxwidth300', 1);
|
||||
} else {
|
||||
print '<input name="' . $constname . '" class="maxwidth200" value="' . dol_escape_htmltag($selected) . '">';
|
||||
}
|
||||
} elseif ($val['type'] == 'accountancy_category') {
|
||||
$selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
print '<input type="text" name="' . $constname . '" list="pcg_type_datalist" value="' . $selected . '">';
|
||||
// autosuggest from existing account types if found
|
||||
print '<datalist id="pcg_type_datalist">';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancysystem.class.php';
|
||||
$accountsystem = new AccountancySystem($db);
|
||||
$accountsystem->fetch($conf->global->CHARTOFACCOUNTS);
|
||||
$sql = 'SELECT DISTINCT pcg_type FROM ' . MAIN_DB_PREFIX . 'accounting_account';
|
||||
$sql .= " WHERE fk_pcg_version = '" . $db->escape($accountsystem->ref) . "'";
|
||||
$sql .= ' AND entity in ('.getEntity('accounting_account', 0).')'; // Always limit to current entity. No sharing in accountancy.
|
||||
$sql .= ' LIMIT 50000'; // just as a sanity check
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
while ($obj = $db->fetch_object($resql)) {
|
||||
print '<option value="' . dol_escape_htmltag($obj->pcg_type) . '">';
|
||||
}
|
||||
}
|
||||
print '</datalist>';
|
||||
} else {
|
||||
print '<input name="' . $constname . '" class="maxwidth200" value="' . dol_escape_htmltag($selected) . '">';
|
||||
}
|
||||
} else {
|
||||
print '<input name="'.$constname.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->{$constname}.'">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
print $form->buttonsSaveCancel("Save", '');
|
||||
print '<br><div class="center">';
|
||||
print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
} else {
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||
if (!empty($arrayofparameters)) {
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
foreach ($arrayofparameters as $key => $val) {
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
|
||||
print '</td><td>'.$conf->global->$key.'</td></tr>';
|
||||
foreach ($arrayofparameters as $constname => $val) {
|
||||
if ($val['enabled']==1) {
|
||||
$setupnotempty++;
|
||||
print '<tr class="oddeven"><td>';
|
||||
$tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
|
||||
print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
|
||||
print '</td><td>';
|
||||
|
||||
if ($val['type'] == 'textarea') {
|
||||
print dol_nl2br($conf->global->{$constname});
|
||||
} elseif ($val['type']== 'html') {
|
||||
print $conf->global->{$constname};
|
||||
} elseif ($val['type'] == 'yesno') {
|
||||
print ajax_constantonoff($constname);
|
||||
} elseif (preg_match('/emailtemplate:/', $val['type'])) {
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
|
||||
$tmp = explode(':', $val['type']);
|
||||
|
||||
$template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname});
|
||||
if ($template<0) {
|
||||
setEventMessages(null, $formmail->errors, 'errors');
|
||||
}
|
||||
print $langs->trans($template->label);
|
||||
} elseif (preg_match('/category:/', $val['type'])) {
|
||||
$c = new Categorie($db);
|
||||
$result = $c->fetch($conf->global->{$constname});
|
||||
if ($result < 0) {
|
||||
setEventMessages(null, $c->errors, 'errors');
|
||||
} elseif ($result > 0 ) {
|
||||
$ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
|
||||
$toprint = array();
|
||||
foreach ($ways as $way) {
|
||||
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
|
||||
}
|
||||
print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
|
||||
}
|
||||
} elseif (preg_match('/thirdparty_type/', $val['type'])) {
|
||||
if ($conf->global->{$constname}==2) {
|
||||
print $langs->trans("Prospect");
|
||||
} elseif ($conf->global->{$constname}==3) {
|
||||
print $langs->trans("ProspectCustomer");
|
||||
} elseif ($conf->global->{$constname}==1) {
|
||||
print $langs->trans("Customer");
|
||||
} elseif ($conf->global->{$constname}==0) {
|
||||
print $langs->trans("NorProspectNorCustomer");
|
||||
}
|
||||
} elseif ($val['type'] == 'product') {
|
||||
$product = new Product($db);
|
||||
$resprod = $product->fetch($conf->global->{$constname});
|
||||
if ($resprod > 0) {
|
||||
print $product->ref;
|
||||
} elseif ($resprod < 0) {
|
||||
setEventMessages(null, $object->errors, "errors");
|
||||
}
|
||||
} elseif ($val['type'] == 'accountancy_code') {
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch('', $conf->global->{$constname}, 1);
|
||||
|
||||
print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
|
||||
} else {
|
||||
print $conf->global->{$constname};
|
||||
}
|
||||
} else {
|
||||
print $conf->global->{$constname};
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
|
||||
print '</div>';
|
||||
} else {
|
||||
print '<br>'.$langs->trans("NothingToSetup");
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
if (empty($setupnotempty)) {
|
||||
print '<br>'.$langs->trans("NothingToSetup");
|
||||
}
|
||||
|
||||
// Page end
|
||||
print dol_get_fiche_end();
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
215
htdocs/asset/agenda.php
Normal file
215
htdocs/asset/agenda.php
Normal file
@ -0,0 +1,215 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/agenda.php
|
||||
* \ingroup asset
|
||||
* \brief Tab of events on Asset
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("assets", "other"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
if (GETPOST('actioncode', 'array')) {
|
||||
$actioncode = GETPOST('actioncode', 'array', 3);
|
||||
if (!count($actioncode)) {
|
||||
$actioncode = '0';
|
||||
}
|
||||
} else {
|
||||
$actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
|
||||
}
|
||||
$search_agenda_label = GETPOST('search_agenda_label');
|
||||
|
||||
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortfield) {
|
||||
$sortfield = 'a.datep,a.id';
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = 'DESC,DESC';
|
||||
}
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new Asset($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('assetagenda', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$upload_dir = $conf->asset->multidir_output[$object->entity]."/".$object->id;
|
||||
}
|
||||
|
||||
$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php
|
||||
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters = array('id'=>$id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
// Cancel
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$actioncode = '';
|
||||
$search_agenda_label = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
if ($object->id > 0) {
|
||||
$title = $langs->trans("Agenda");
|
||||
//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
|
||||
$help_url = 'EN:Module_Agenda_En';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if (!empty($conf->notification->enabled)) {
|
||||
$langs->load("mails");
|
||||
}
|
||||
$head = assetPrepareHead($object);
|
||||
|
||||
|
||||
print dol_get_fiche_head($head, 'agenda', $langs->trans("Asset"), -1, $object->picto);
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/asset/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
$object->info($object->id);
|
||||
dol_print_object_info($object, 1);
|
||||
|
||||
print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
|
||||
// Actions buttons
|
||||
|
||||
$objthirdparty = $object;
|
||||
$objcon = new stdClass();
|
||||
|
||||
$out = '&origin=' . urlencode($object->element . '@' . $object->module) . '&originid=' . urlencode($object->id);
|
||||
$urlbacktopage = $_SERVER['PHP_SELF'] . '?id=' . $object->id;
|
||||
$out .= '&backtopage=' . urlencode($urlbacktopage);
|
||||
$permok = $user->rights->agenda->myactions->create;
|
||||
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
|
||||
//$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
|
||||
if (get_class($objthirdparty) == 'Societe') {
|
||||
$out .= '&socid=' . urlencode($objthirdparty->id);
|
||||
}
|
||||
$out .= (!empty($objcon->id) ? '&contactid=' . urlencode($objcon->id) : '') . '&percentage=-1';
|
||||
//$out.=$langs->trans("AddAnAction").' ';
|
||||
//$out.=img_picto($langs->trans("AddAnAction"),'filenew');
|
||||
//$out.="</a>";
|
||||
}
|
||||
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if (!empty($conf->agenda->enabled)) {
|
||||
if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
|
||||
print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create' . $out . '">' . $langs->trans("AddAction") . '</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#">' . $langs->trans("AddAction") . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
|
||||
$param = '&id=' . $object->id . '&socid=' . $socid;
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage=' . urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit=' . urlencode($limit);
|
||||
}
|
||||
|
||||
|
||||
print load_fiche_titre($langs->trans("ActionsOnAsset"), '', '');
|
||||
|
||||
// List of all actions
|
||||
$filters = array();
|
||||
$filters['search_agenda_label'] = $search_agenda_label;
|
||||
|
||||
// TODO Replace this with same code than into list.php
|
||||
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
|
||||
}
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("asset"));
|
||||
$langs->loadLangs(array("assets", "other"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
@ -68,12 +68,6 @@ if (empty($action) && empty($id) && empty($ref)) {
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
|
||||
|
||||
// Security check
|
||||
if (!empty($user->socid)) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'asset', $id);
|
||||
|
||||
$permissiontoread = $user->rights->asset->read;
|
||||
$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||
$permissiontodelete = $user->rights->asset->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
||||
@ -81,7 +75,13 @@ $permissionnote = $user->rights->asset->write; // Used by the include of actions
|
||||
$permissiondellink = $user->rights->asset->write; // Used by the include of actions_dellink.inc.php
|
||||
$upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1];
|
||||
|
||||
$error = 0;
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
if ($user->socid > 0) $socid = $user->socid;
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
@ -95,6 +95,8 @@ if ($reshook < 0) {
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
$error = 0;
|
||||
|
||||
$backurlforlist = DOL_URL_ROOT.'/asset/list.php';
|
||||
|
||||
if (empty($backtopage) || ($cancel && empty($id))) {
|
||||
@ -107,6 +109,27 @@ if (empty($reshook)) {
|
||||
}
|
||||
}
|
||||
|
||||
$object->oldcopy = dol_clone($object);
|
||||
$triggermodname = 'ASSET_MODIFY'; // Name of trigger action code to execute when we modify record
|
||||
|
||||
// Action dispose object
|
||||
if ($action == 'confirm_disposal' && $confirm == 'yes' && $permissiontoadd) {
|
||||
$object->disposal_date = dol_mktime(12, 0, 0, GETPOST('disposal_datemonth', 'int'), GETPOST('disposal_dateday', 'int'), GETPOST('disposal_dateyear', 'int')); // for date without hour, we use gmt
|
||||
$object->disposal_amount_ht = GETPOST('disposal_amount', 'int');
|
||||
$object->fk_disposal_type = GETPOST('fk_disposal_type', 'int');
|
||||
$disposal_invoice_id = GETPOST('disposal_invoice_id', 'int');
|
||||
$object->disposal_depreciated = ((GETPOST('disposal_depreciated') == '1' || GETPOST('disposal_depreciated') == 'on') ? 1 : 0);
|
||||
$object->disposal_subject_to_vat = ((GETPOST('disposal_subject_to_vat') == '1' || GETPOST('disposal_subject_to_vat') == 'on') ? 1 : 0);
|
||||
|
||||
$result = $object->dispose($user, $disposal_invoice_id);
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
$action = '';
|
||||
} elseif ($action == "add") {
|
||||
$object->supplier_invoice_id = GETPOST('supplier_invoice_id', 'int');
|
||||
}
|
||||
|
||||
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
||||
|
||||
@ -122,13 +145,6 @@ if (empty($reshook)) {
|
||||
// Action to build doc
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
|
||||
if ($action == 'set_thirdparty' && $permissiontoadd) {
|
||||
$object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MYOBJECT_MODIFY');
|
||||
}
|
||||
if ($action == 'classin' && $permissiontoadd) {
|
||||
$object->setProject(GETPOST('projectid', 'int'));
|
||||
}
|
||||
|
||||
// Actions to send emails
|
||||
$triggersendname = 'ASSET_SENTBYMAIL';
|
||||
$autocopy = 'MAIN_MAIL_AUTOCOPY_ASSET_TO';
|
||||
@ -136,6 +152,7 @@ if (empty($reshook)) {
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*
|
||||
@ -150,7 +167,7 @@ llxHeader('', $title, $help_url);
|
||||
|
||||
// Part to create
|
||||
if ($action == 'create') {
|
||||
print load_fiche_titre($langs->trans("NewAsset"), '', $object->picto);
|
||||
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Asset")), '', 'object_'.$object->picto);
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
@ -161,9 +178,16 @@ if ($action == 'create') {
|
||||
if ($backtopageforcancel) {
|
||||
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
|
||||
}
|
||||
if (GETPOSTISSET('supplier_invoice_id')) {
|
||||
$object->fields['supplier_invoice_id'] = array('type' => 'integer:FactureFournisseur:fourn/class/fournisseur.facture.class.php:1:entity IN (__SHARED_ENTITIES__)', 'label' => 'SupplierInvoice', 'enabled' => '1', 'noteditable' => '1', 'position' => 280, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'validate' => '1',);
|
||||
print '<input type="hidden" name="supplier_invoice_id" value="' . GETPOST('supplier_invoice_id', 'int') . '">';
|
||||
}
|
||||
|
||||
print dol_get_fiche_head(array(), '');
|
||||
|
||||
// Set some default values
|
||||
//if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
|
||||
|
||||
print '<table class="border centpercent tableforfieldcreate">'."\n";
|
||||
|
||||
// Common attributes
|
||||
@ -185,12 +209,11 @@ if ($action == 'create') {
|
||||
|
||||
// Part to edit record
|
||||
if (($id || $ref) && $action == 'edit') {
|
||||
print load_fiche_titre($langs->trans("Assets"));
|
||||
print load_fiche_titre($langs->trans("Asset"), '', 'object_'.$object->picto);
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
if ($backtopage) {
|
||||
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||
@ -222,18 +245,60 @@ if (($id || $ref) && $action == 'edit') {
|
||||
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
|
||||
$res = $object->fetch_optionals();
|
||||
|
||||
$head = asset_prepare_head($object);
|
||||
$head = assetPrepareHead($object);
|
||||
print dol_get_fiche_head($head, 'card', $langs->trans("Asset"), -1, $object->picto);
|
||||
|
||||
$formconfirm = '';
|
||||
|
||||
// Confirmation to delete
|
||||
if ($action == 'delete') {
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteAssets'), $langs->trans('ConfirmDeleteAsset'), 'confirm_delete', '', 0, 1);
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteAsset'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
|
||||
} elseif ($action == 'disposal') {
|
||||
// Disposal
|
||||
$langs->load('bills');
|
||||
|
||||
$disposal_date = dol_mktime(12, 0, 0, GETPOST('disposal_datemonth', 'int'), GETPOST('disposal_dateday', 'int'), GETPOST('disposal_dateyear', 'int')); // for date without hour, we use gmt
|
||||
$disposal_amount = GETPOST('disposal_amount', 'int');
|
||||
$fk_disposal_type = GETPOST('fk_disposal_type', 'int');
|
||||
$disposal_invoice_id = GETPOST('disposal_invoice_id', 'int');
|
||||
$disposal_depreciated = GETPOSTISSET('disposal_depreciated') ? GETPOST('disposal_depreciated') : 1;
|
||||
$disposal_depreciated = !empty($disposal_depreciated) ? 1 : 0;
|
||||
$disposal_subject_to_vat = GETPOSTISSET('disposal_subject_to_vat') ? GETPOST('disposal_subject_to_vat') : 1;
|
||||
$disposal_subject_to_vat = !empty($disposal_subject_to_vat) ? 1 : 0;
|
||||
|
||||
$object->fields['fk_disposal_type']['visible'] = 1;
|
||||
$disposal_type_form = $object->showInputField(null, 'fk_disposal_type', $fk_disposal_type, '', '', '', 0);
|
||||
$object->fields['fk_disposal_type']['visible'] = -2;
|
||||
|
||||
$object->fields['disposal_invoice_id'] = array('type' => 'integer:Facture:compta/facture/class/facture.class.php::entity IN (__SHARED_ENTITIES__)', 'enabled' => '1', 'notnull' => 1, 'visible' => 1, 'index' => 1, 'validate' => '1',);
|
||||
$disposal_invoice_form = $object->showInputField(null, 'disposal_invoice_id', $disposal_invoice_id, '', '', '', 0);
|
||||
unset($object->fields['disposal_invoice_id']);
|
||||
|
||||
// Create an array for form
|
||||
$formquestion = array(
|
||||
array('type' => 'date', 'name' => 'disposal_date', 'tdclass' => 'fieldrequired', 'label' => $langs->trans("AssetDisposalDate"), 'value' => $disposal_date),
|
||||
array('type' => 'text', 'name' => 'disposal_amount', 'tdclass' => 'fieldrequired', 'label' => $langs->trans("AssetDisposalAmount"), 'value' => $disposal_amount),
|
||||
array('type' => 'other', 'name' => 'fk_disposal_type', 'tdclass' => 'fieldrequired', 'label' => $langs->trans("AssetDisposalType"), 'value' => $disposal_type_form),
|
||||
array('type' => 'other', 'name' => 'disposal_invoice_id', 'label' => $langs->trans("InvoiceCustomer"), 'value' => $disposal_invoice_form),
|
||||
array('type' => 'checkbox', 'name' => 'disposal_depreciated', 'label' => $langs->trans("AssetDisposalDepreciated"), 'value' => $disposal_depreciated),
|
||||
array('type' => 'checkbox', 'name' => 'disposal_subject_to_vat', 'label' => $langs->trans("AssetDisposalSubjectToVat"), 'value' => $disposal_subject_to_vat),
|
||||
);
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('AssetDisposal'), $langs->trans('AssetConfirmDisposalAsk', $object->ref . ' - ' . $object->label), 'confirm_disposal', $formquestion, 'yes', 1);
|
||||
} elseif ($action == 'reopen') {
|
||||
// Re-open
|
||||
// Create an array for form
|
||||
$formquestion = array();
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('AssetConfirmReOpenAsk', $object->ref), 'confirm_reopen', $formquestion, 'yes', 1);
|
||||
}
|
||||
// Clone confirmation
|
||||
/* elseif ($action == 'clone') {
|
||||
// Create an array for form
|
||||
$formquestion = array();
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
|
||||
}*/
|
||||
|
||||
// Call Hook formConfirm
|
||||
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
|
||||
$parameters = array('formConfirm' => $formconfirm);
|
||||
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) {
|
||||
$formconfirm .= $hookmanager->resPrint;
|
||||
@ -250,24 +315,19 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/asset/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
/*
|
||||
// Ref bis
|
||||
$morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->asset->creer, 'string', '', 0, 1);
|
||||
$morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->asset->creer, 'string', '', null, null, '', 1);
|
||||
// Thirdparty
|
||||
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
|
||||
*/
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">'."\n";
|
||||
print '<table class="border centpercent tableforfield">'."\n";
|
||||
|
||||
// Common attributes
|
||||
//$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just after this field
|
||||
$keyforbreak='date_acquisition'; // We change column just before this field
|
||||
//unset($object->fields['fk_project']); // Hide field already shown in banner
|
||||
//unset($object->fields['fk_soc']); // Hide field already shown in banner
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
|
||||
@ -277,69 +337,100 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '<div class="clearboth"></div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
|
||||
/*
|
||||
* Buttons
|
||||
*/
|
||||
if ($user->socid == 0) {
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
// Buttons for actions
|
||||
if ($action != 'presend' && $action != 'editline') {
|
||||
print '<div class="tabsAction">' . "\n";
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
if ($user->rights->asset->write) {
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>'."\n";
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
|
||||
// Send
|
||||
if (empty($user->socid)) {
|
||||
print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init&token=' . newToken() . '#formmailbeforetitle');
|
||||
}
|
||||
|
||||
if ($user->rights->asset->delete) {
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n";
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
|
||||
if ($object->status == $object::STATUS_DRAFT) {
|
||||
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit&token=' . newToken(), '', $permissiontoadd);
|
||||
}
|
||||
|
||||
// Clone
|
||||
//print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=clone&token=' . newToken(), '', false && $permissiontoadd);
|
||||
|
||||
if ($object->status == $object::STATUS_DRAFT) {
|
||||
print dolGetButtonAction($langs->trans('AssetDisposal'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=disposal&token=' . newToken(), '', $permissiontoadd);
|
||||
} else {
|
||||
print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=reopen&token=' . newToken(), '', $permissiontoadd);
|
||||
}
|
||||
|
||||
// Delete (need delete permission, or if draft, just need create/modify permission)
|
||||
print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
|
||||
}
|
||||
print "</div>";
|
||||
print '</div>' . "\n";
|
||||
}
|
||||
|
||||
// Select mail models is same action as presend
|
||||
if (GETPOST('modelselected')) {
|
||||
$action = 'presend';
|
||||
}
|
||||
|
||||
if ($action != 'presend') {
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
print '<a name="builddoc"></a>'; // ancre
|
||||
|
||||
// Documents
|
||||
$filename = dol_sanitizeFileName($object->ref);
|
||||
$filedir = $conf->contrat->dir_output."/".dol_sanitizeFileName($object->ref);
|
||||
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
|
||||
$genallowed = $user->rights->asset->read; // If you can read, you can build the PDF to read content
|
||||
$delallowed = $user->rights->asset->write; // If you can create/edit, you can remove a file on card
|
||||
$includedocgeneration = 0;
|
||||
|
||||
print $formfile->showdocuments('asset', $filename, $filedir, $urlsource, 0, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
||||
// Documents
|
||||
if ($includedocgeneration) {
|
||||
$objref = dol_sanitizeFileName($object->ref);
|
||||
$relativepath = $objref.'/'.$objref.'.pdf';
|
||||
$filedir = $conf->asset->dir_output.'/'.$objref;
|
||||
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
|
||||
$genallowed = $user->rights->asset->read; // If you can read, you can build the PDF to read content
|
||||
$delallowed = $user->rights->asset->write; // If you can create/edit, you can remove a file on card
|
||||
print $formfile->showdocuments('asset:Asset', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
|
||||
}
|
||||
|
||||
// Show links to link elements
|
||||
$linktoelem = $form->showLinkToObjectBlock($object, null, array('asset'));
|
||||
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
||||
|
||||
|
||||
print '</div><div class="fichehalfright">';
|
||||
|
||||
$MAXEVENT = 10;
|
||||
|
||||
$morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/asset/info.php?id='.$object->id);
|
||||
$morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/asset/agenda.php?id='.$object->id);
|
||||
|
||||
// List of actions on element
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
||||
$formactions = new FormActions($db);
|
||||
$somethingshown = $formactions->showactions($object, $object->element, $socid, 1, '', $MAXEVENT, '', $morehtmlright);
|
||||
$somethingshown = $formactions->showactions($object, $object->element, 0, 1, '', $MAXEVENT, '', $morehtmlright);
|
||||
|
||||
print '</div></div>';
|
||||
}
|
||||
}
|
||||
|
||||
//Select mail models is same action as presend
|
||||
if (GETPOST('modelselected')) {
|
||||
$action = 'presend';
|
||||
}
|
||||
|
||||
// Presend form
|
||||
$modelmail = 'asset';
|
||||
$defaulttopic = 'InformationMessage';
|
||||
$diroutput = $conf->asset->dir_output;
|
||||
$trackid = 'asset'.$object->id;
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,445 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/class/asset_type.class.php
|
||||
* \ingroup asset
|
||||
* \brief File of class to manage asset types
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage asset type
|
||||
*/
|
||||
class AssetType extends CommonObject
|
||||
{
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
public $table_element = 'asset_type';
|
||||
|
||||
/**
|
||||
* @var string ID to identify managed object
|
||||
*/
|
||||
public $element = 'asset_type';
|
||||
|
||||
/**
|
||||
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
|
||||
*/
|
||||
public $picto = 'asset';
|
||||
|
||||
/**
|
||||
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
* @var int
|
||||
*/
|
||||
public $ismultientitymanaged = 1;
|
||||
|
||||
/**
|
||||
* @var string Asset type label
|
||||
*/
|
||||
public $label;
|
||||
|
||||
/** @var string Accountancy code asset */
|
||||
public $accountancy_code_asset;
|
||||
|
||||
/** @var string Accountancy code depreciation asset */
|
||||
public $accountancy_code_depreciation_asset;
|
||||
|
||||
/** @var string Accountancy code depreciation expense */
|
||||
public $accountancy_code_depreciation_expense;
|
||||
|
||||
/** @var string Public note */
|
||||
public $note;
|
||||
|
||||
/** @var array Array of asset */
|
||||
public $asset = array();
|
||||
|
||||
public $fields = array(
|
||||
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
|
||||
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20),
|
||||
'label' =>array('type'=>'varchar(50)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25, 'showoncombobox'=>1),
|
||||
'accountancy_code_asset' =>array('type'=>'varchar(32)', 'label'=>'Accountancy code asset', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
|
||||
'accountancy_code_depreciation_asset' =>array('type'=>'varchar(32)', 'label'=>'Accountancy code depreciation asset', 'enabled'=>1, 'visible'=>-1, 'position'=>35),
|
||||
'accountancy_code_depreciation_expense' =>array('type'=>'varchar(32)', 'label'=>'Accountancy code depreciation expense', 'enabled'=>1, 'visible'=>-1, 'position'=>40),
|
||||
'note' =>array('type'=>'mediumtext', 'label'=>'Note', 'enabled'=>1, 'visible'=>-1, 'position'=>45),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fonction qui permet de creer le type d'immobilisation
|
||||
*
|
||||
* @param User $user User making creation
|
||||
* @param int $notrigger 1=do not execute triggers, 0 otherwise
|
||||
* @return int >0 if OK, < 0 if KO
|
||||
*/
|
||||
public function create($user, $notrigger = 0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$error = 0;
|
||||
|
||||
$this->label = trim($this->label);
|
||||
$this->accountancy_code_asset = trim($this->accountancy_code_asset);
|
||||
$this->accountancy_code_depreciation_asset = trim($this->accountancy_code_depreciation_asset);
|
||||
$this->accountancy_code_depreciation_expense = trim($this->accountancy_code_depreciation_expense);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."asset_type (";
|
||||
$sql .= "label";
|
||||
$sql .= ", accountancy_code_asset";
|
||||
$sql .= ", accountancy_code_depreciation_asset";
|
||||
$sql .= ", accountancy_code_depreciation_expense";
|
||||
$sql .= ", note";
|
||||
$sql .= ", entity";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= "'".$this->db->escape($this->label)."'";
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_asset)."'";
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'";
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'";
|
||||
$sql .= ", '".$this->db->escape($this->note)."'";
|
||||
$sql .= ", ".((int) $conf->entity);
|
||||
$sql .= ")";
|
||||
|
||||
dol_syslog("Asset_type::create", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."asset_type");
|
||||
|
||||
$result = $this->update($user, 1);
|
||||
if ($result < 0) {
|
||||
$this->db->rollback();
|
||||
return -3;
|
||||
}
|
||||
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('ASSET_TYPE_CREATE', $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
} else {
|
||||
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Met a jour en base donnees du type
|
||||
*
|
||||
* @param User $user Object user making change
|
||||
* @param int $notrigger 1=do not execute triggers, 0 otherwise
|
||||
* @return int >0 if OK, < 0 if KO
|
||||
*/
|
||||
public function update($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $hookmanager;
|
||||
|
||||
$error = 0;
|
||||
|
||||
$this->label = trim($this->label);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."asset_type ";
|
||||
$sql .= "SET ";
|
||||
$sql .= "label = '".$this->db->escape($this->label)."',";
|
||||
$sql .= "accountancy_code_asset = '".$this->db->escape($this->accountancy_code_asset)."',";
|
||||
$sql .= "accountancy_code_depreciation_asset = '".$this->db->escape($this->accountancy_code_depreciation_asset)."',";
|
||||
$sql .= "accountancy_code_depreciation_expense = '".$this->db->escape($this->accountancy_code_depreciation_expense)."',";
|
||||
$sql .= "note = '".$this->db->escape($this->note)."'";
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$action = 'update';
|
||||
|
||||
// Actions on extra fields
|
||||
if (!$error) {
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('ASSET_TYPE_MODIFY', $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
|
||||
return -$error;
|
||||
}
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction qui permet de supprimer le status de l'adherent
|
||||
*
|
||||
* @return int >0 if OK, 0 if not found, < 0 if KO
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$error = 0;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."asset_type";
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('ASSET_TYPE_DELETE', $user);
|
||||
if ($result < 0) {
|
||||
$error++; $this->db->rollback(); return -2;
|
||||
}
|
||||
// End call triggers
|
||||
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction qui permet de recuperer le status de l'immobilisation
|
||||
*
|
||||
* @param int $rowid Id of member type to load
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetch($rowid)
|
||||
{
|
||||
$sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d";
|
||||
$sql .= " WHERE d.rowid = ".(int) $rowid;
|
||||
|
||||
dol_syslog("Asset_type::fetch", LOG_DEBUG);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->label = $obj->label;
|
||||
$this->accountancy_code_asset = $obj->accountancy_code_asset;
|
||||
$this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset;
|
||||
$this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense;
|
||||
$this->note = $obj->note;
|
||||
}
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return list of asset's type
|
||||
*
|
||||
* @return array List of types of members
|
||||
*/
|
||||
public function liste_array()
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs;
|
||||
|
||||
$assettypes = array();
|
||||
|
||||
$sql = "SELECT rowid, label as label";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."asset_type";
|
||||
$sql .= " WHERE entity IN (".getEntity('asset_type').")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$nump = $this->db->num_rows($resql);
|
||||
|
||||
if ($nump) {
|
||||
$i = 0;
|
||||
while ($i < $nump) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$assettypes[$obj->rowid] = $langs->trans($obj->label);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print $this->db->error();
|
||||
}
|
||||
return $assettypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array of Asset objects for asset type this->id (or all if this->id not defined)
|
||||
*
|
||||
* @param string $excludefilter Filter string to exclude. This parameter must not be provided by input of users
|
||||
* @param int $mode 0=Return array of asset instance
|
||||
* 1=Return array of asset instance without extra data
|
||||
* 2=Return array of asset id only
|
||||
* @return mixed Array of asset or -1 on error
|
||||
*/
|
||||
public function listAssetForAssetType($excludefilter = '', $mode = 0)
|
||||
{
|
||||
global $conf, $user;
|
||||
|
||||
$ret = array();
|
||||
|
||||
$sql = "SELECT a.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."asset as a";
|
||||
$sql .= " WHERE a.entity IN (".getEntity('asset').")";
|
||||
$sql .= " AND a.fk_asset_type = ".((int) $this->id);
|
||||
if (!empty($excludefilter)) {
|
||||
$sql .= ' AND ('.$excludefilter.')';
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::listAssetsForGroup", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
if (!array_key_exists($obj->rowid, $ret)) {
|
||||
if ($mode < 2) {
|
||||
$assetstatic = new Asset($this->db);
|
||||
$assetstatic->fetch($obj->rowid);
|
||||
$ret[$obj->rowid] = $assetstatic;
|
||||
} else {
|
||||
$ret[$obj->rowid] = $obj->rowid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
$this->asset = $ret;
|
||||
|
||||
return $ret;
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return clicable name (with picto eventually)
|
||||
*
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||
* @param int $maxlen length max label
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @return string String with URL
|
||||
*/
|
||||
public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$result = '';
|
||||
$label = $langs->trans("ShowTypeCard", $this->label);
|
||||
|
||||
$linkstart = '<a href="'.DOL_URL_ROOT.'/asset/type.php?rowid='.((int) $this->id).'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$linkend = '</a>';
|
||||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) {
|
||||
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
|
||||
}
|
||||
$result .= $linkend;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise an instance with random values.
|
||||
* Used to build previews or test instances.
|
||||
* id must be 0 if object instance is a specimen.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initAsSpecimen()
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
// Initialize parameters
|
||||
$this->id = 0;
|
||||
$this->ref = 'ATSPEC';
|
||||
$this->specimen = 1;
|
||||
|
||||
$this->label = 'ASSET TYPE SPECIMEN';
|
||||
$this->note = 'This is a note';
|
||||
|
||||
// Assets of this asset type is just me
|
||||
$this->asset = array(
|
||||
$user->id => $user
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* getLibStatut
|
||||
*
|
||||
* @return string Return status of a type of asset
|
||||
*/
|
||||
public function getLibStatut()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
279
htdocs/asset/class/assetaccountancycodes.class.php
Normal file
279
htdocs/asset/class/assetaccountancycodes.class.php
Normal file
@ -0,0 +1,279 @@
|
||||
<?php
|
||||
/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file asset/class/assetaccountancycodes.class.php
|
||||
* \ingroup asset
|
||||
* \brief This file is a class file for AssetAccountancyCodes
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
|
||||
/**
|
||||
* Class for AssetAccountancyCodes
|
||||
*/
|
||||
class AssetAccountancyCodes extends CommonObject
|
||||
{
|
||||
/**
|
||||
* @var array Array with all accountancy codes info by mode.
|
||||
* Note : 'economic' mode is mandatory and is the primary accountancy codes
|
||||
* 'depreciation_asset' and 'depreciation_expense' is mandatory and is used for write depreciation in bookkeeping
|
||||
*/
|
||||
public $accountancy_codes_fields = array(
|
||||
'economic' => array(
|
||||
'label' => 'AssetAccountancyCodeDepreciationEconomic',
|
||||
'table' => 'asset_accountancy_codes_economic',
|
||||
'depreciation_debit' => 'depreciation_asset',
|
||||
'depreciation_credit' => 'depreciation_expense',
|
||||
'fields' => array(
|
||||
'asset' => array('label' => 'AssetAccountancyCodeAsset'),
|
||||
'depreciation_asset' => array('label' => 'AssetAccountancyCodeDepreciationAsset'),
|
||||
'depreciation_expense' => array('label' => 'AssetAccountancyCodeDepreciationExpense'),
|
||||
'value_asset_sold' => array('label' => 'AssetAccountancyCodeValueAssetSold'),
|
||||
'receivable_on_assignment' => array('label' => 'AssetAccountancyCodeReceivableOnAssignment'),
|
||||
'proceeds_from_sales' => array('label' => 'AssetAccountancyCodeProceedsFromSales'),
|
||||
'vat_collected' => array('label' => 'AssetAccountancyCodeVatCollected'),
|
||||
'vat_deductible' => array('label' => 'AssetAccountancyCodeVatDeductible'),
|
||||
),
|
||||
),
|
||||
'accelerated_depreciation' => array(
|
||||
'label' => 'AssetAccountancyCodeDepreciationAcceleratedDepreciation',
|
||||
'table' => 'asset_accountancy_codes_fiscal',
|
||||
'depreciation_debit' => 'accelerated_depreciation',
|
||||
'depreciation_credit' => 'endowment_accelerated_depreciation',
|
||||
'fields' => array(
|
||||
'accelerated_depreciation' => array('label' => 'AssetAccountancyCodeAcceleratedDepreciation'),
|
||||
'endowment_accelerated_depreciation' => array('label' => 'AssetAccountancyCodeEndowmentAcceleratedDepreciation'),
|
||||
'provision_accelerated_depreciation' => array('label' => 'AssetAccountancyCodeProvisionAcceleratedDepreciation'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* @var array Array with all accountancy codes by mode.
|
||||
*/
|
||||
public $accountancy_codes = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDb $db Database handler
|
||||
*/
|
||||
public function __construct(DoliDB $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill accountancy_codes property of object (using for data sent by forms)
|
||||
*
|
||||
* @return array Array of values
|
||||
*/
|
||||
public function setAccountancyCodesFromPost()
|
||||
{
|
||||
$this->accountancy_codes = array();
|
||||
foreach ($this->accountancy_codes_fields as $mode_key => $mode_info) {
|
||||
$this->accountancy_codes[$mode_key] = array();
|
||||
foreach ($mode_info['fields'] as $field_key => $field_info) {
|
||||
$accountancy_code = GETPOST($mode_key . '_' . $field_key, 'aZ09');
|
||||
if (empty($accountancy_code) || $accountancy_code == '-1') $accountancy_code = '';
|
||||
$this->accountancy_codes[$mode_key][$field_key] = $accountancy_code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load accountancy codes of a asset or a asset model
|
||||
*
|
||||
* @param int $asset_id Asset ID to set
|
||||
* @param int $asset_model_id Asset model ID to set
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetchAccountancyCodes($asset_id = 0, $asset_model_id = 0)
|
||||
{
|
||||
global $langs, $hookmanager;
|
||||
dol_syslog(__METHOD__ . " asset_id=$asset_id, asset_model_id=$asset_model_id");
|
||||
|
||||
$error = 0;
|
||||
$this->errors = array();
|
||||
$this->accountancy_codes = array();
|
||||
|
||||
// Clean parameters
|
||||
$asset_id = $asset_id > 0 ? $asset_id : 0;
|
||||
$asset_model_id = $asset_model_id > 0 ? $asset_model_id : 0;
|
||||
|
||||
if (!is_object($hookmanager)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
|
||||
$hookmanager->initHooks(array('assetaccountancycodesdao'));
|
||||
$parameters = array('asset_id' => $asset_id, 'asset_model_id' => $asset_model_id);
|
||||
$reshook = $hookmanager->executeHooks('fetchAccountancyCodes', $parameters, $this); // Note that $action and $object may have been modified by some hooks
|
||||
if (!empty($reshook)) {
|
||||
return $reshook;
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
if (empty($asset_id) && empty($asset_model_id)) {
|
||||
$this->errors[] = $langs->trans('AssetErrorAssetOrAssetModelIDNotProvide');
|
||||
$error++;
|
||||
}
|
||||
if ($error) {
|
||||
dol_syslog(__METHOD__ . " Error check parameters: " . $this->errorsToString(), LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$accountancy_codes = array();
|
||||
foreach ($this->accountancy_codes_fields as $mode_key => $mode_info) {
|
||||
$sql = "SELECT " . implode(',', array_keys($mode_info['fields']));
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . $mode_info['table'];
|
||||
$sql .= " WHERE " . ($asset_id > 0 ? " fk_asset = " . (int) $asset_id : " fk_asset_model = " . (int) $asset_model_id);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
if ($obj = $this->db->fetch_object($resql)) {
|
||||
$accountancy_codes[$mode_key] = array();
|
||||
foreach ($mode_info['fields'] as $field_key => $field_info) {
|
||||
$accountancy_codes[$mode_key][$field_key] = $obj->$field_key;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $langs->trans('AssetErrorFetchAccountancyCodesForMode', $mode_key) . ': ' . $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
dol_syslog(__METHOD__ . " Error fetch accountancy codes: " . $this->errorsToString(), LOG_ERR);
|
||||
return -1;
|
||||
} else {
|
||||
$this->accountancy_codes = $accountancy_codes;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update accountancy codes of a asset or a asset model
|
||||
*
|
||||
* @param User $user User making update
|
||||
* @param int $asset_id Asset ID to set
|
||||
* @param int $asset_model_id Asset model ID to set
|
||||
* @param int $notrigger 1=disable trigger UPDATE (when called by create)
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function updateAccountancyCodes($user, $asset_id = 0, $asset_model_id = 0, $notrigger = 0)
|
||||
{
|
||||
global $langs, $hookmanager;
|
||||
dol_syslog(__METHOD__ . " user_id={$user->id}, asset_id=$asset_id, asset_model_id=$asset_model_id, notrigger=$notrigger");
|
||||
|
||||
$error = 0;
|
||||
$this->errors = array();
|
||||
|
||||
// Clean parameters
|
||||
$asset_id = $asset_id > 0 ? $asset_id : 0;
|
||||
$asset_model_id = $asset_model_id > 0 ? $asset_model_id : 0;
|
||||
|
||||
if (!is_object($hookmanager)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
|
||||
$hookmanager->initHooks(array('assetaccountancycodesdao'));
|
||||
$parameters = array('user' => $user, 'asset_id' => $asset_id, 'asset_model_id' => $asset_model_id);
|
||||
$reshook = $hookmanager->executeHooks('updateAccountancyCodes', $parameters, $this); // Note that $action and $object may have been modified by some hooks
|
||||
if (!empty($reshook)) {
|
||||
return $reshook;
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
if (empty($asset_id) && empty($asset_model_id)) {
|
||||
$this->errors[] = $langs->trans('AssetErrorAssetOrAssetModelIDNotProvide');
|
||||
$error++;
|
||||
}
|
||||
if ($error) {
|
||||
dol_syslog(__METHOD__ . " Error check parameters: " . $this->errorsToString(), LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
$now = dol_now();
|
||||
|
||||
foreach ($this->accountancy_codes_fields as $mode_key => $mode_info) {
|
||||
// Delete old accountancy codes
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . $mode_info['table'];
|
||||
$sql .= " WHERE " . ($asset_id > 0 ? " fk_asset = " . (int) $asset_id : " fk_asset_model = " . (int) $asset_model_id);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$this->errors[] = $langs->trans('AssetErrorDeleteAccountancyCodesForMode', $mode_key) . ': ' . $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error && !empty($this->accountancy_codes[$mode_key])) {
|
||||
// Insert accountancy codes
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . $mode_info['table'] . "(";
|
||||
$sql .= $asset_id > 0 ? "fk_asset," : "fk_asset_model,";
|
||||
$sql .= implode(',', array_keys($mode_info['fields']));
|
||||
$sql .= ", tms, fk_user_modif";
|
||||
$sql .= ") VALUES(";
|
||||
$sql .= $asset_id > 0 ? $asset_id : $asset_model_id;
|
||||
foreach ($mode_info['fields'] as $field_key => $field_info) {
|
||||
$sql .= ', ' . (empty($this->accountancy_codes[$mode_key][$field_key]) ? 'NULL' : "'" . $this->db->escape($this->accountancy_codes[$mode_key][$field_key]) . "'");
|
||||
}
|
||||
$sql .= ", '" . $this->db->idate($now) . "'";
|
||||
$sql .= ", " . $user->id;
|
||||
$sql .= ")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$this->errors[] = $langs->trans('AssetErrorInsertAccountancyCodesForMode', $mode_key) . ': ' . $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && $asset_id > 0) {
|
||||
// Calculation of depreciation lines (reversal and future)
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php';
|
||||
$asset = new Asset($this->db);
|
||||
$result = $asset->fetch($asset_id);
|
||||
if ($result > 0) $result = $asset->calculationDepreciation();
|
||||
if ($result < 0) {
|
||||
$this->errors[] = $langs->trans('AssetErrorCalculationDepreciationLines');
|
||||
$this->errors[] = $asset->errorsToString();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('ASSET_ACCOUNTANCY_CODES_MODIFY', $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
546
htdocs/asset/class/assetdepreciationoptions.class.php
Normal file
546
htdocs/asset/class/assetdepreciationoptions.class.php
Normal file
@ -0,0 +1,546 @@
|
||||
<?php
|
||||
/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file asset/class/assetdepreciationoptions.class.php
|
||||
* \ingroup asset
|
||||
* \brief This file is a class file for AssetDepreciationOptions
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
|
||||
/**
|
||||
* Class for AssetDepreciationOptions
|
||||
*/
|
||||
class AssetDepreciationOptions extends CommonObject
|
||||
{
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
|
||||
*/
|
||||
public $table_element = '';
|
||||
|
||||
/**
|
||||
* 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
|
||||
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
|
||||
* 'label' the translation key.
|
||||
* 'picto' is code of a picto to show before value in forms
|
||||
* 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)
|
||||
* 'position' is the sort order of field.
|
||||
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
|
||||
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
* 'noteditable' says if field is not editable (1 or 0)
|
||||
* 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
|
||||
* 'index' if we want an index in database.
|
||||
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
|
||||
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
|
||||
* 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage)
|
||||
* 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
|
||||
* 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
|
||||
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
|
||||
* 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
|
||||
* 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar'
|
||||
* 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
|
||||
* 'comment' is not used. You can store here any text of your choice. It is not used by application.
|
||||
* 'validate' is 1 if need to validate with $this->validateField()
|
||||
* 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value)
|
||||
* 'enabled_field' if the mode block or a field is enabled if another field equal a value (="mode_key:field_key:value")
|
||||
* 'only_on_asset' is 1 if only a field on a asset
|
||||
*
|
||||
* Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
|
||||
*/
|
||||
public $fields = array();
|
||||
|
||||
/**
|
||||
* @var array Array with all deprecation options info by mode.
|
||||
* Note : economic mode is mandatory and is the primary options
|
||||
*/
|
||||
public $deprecation_options_fields = array(
|
||||
'economic' => array(
|
||||
'label' => 'AssetDepreciationOptionEconomic',
|
||||
'table' => 'asset_depreciation_options_economic',
|
||||
'fields' => array(
|
||||
'depreciation_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDepreciationType', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDepreciationTypeLinear', '1'=>'AssetDepreciationOptionDepreciationTypeDegressive', '2'=>'AssetDepreciationOptionDepreciationTypeExceptional'), 'validate'=>'1',),
|
||||
'degressive_coefficient' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionDegressiveRate', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1','enabled_field' => 'economic:depreciation_type:1'),
|
||||
'duration' => array('type'=>'integer', 'label'=>'AssetDepreciationOptionDuration', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
|
||||
'duration_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDurationType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDurationTypeAnnual', '1'=>'AssetDepreciationOptionDurationTypeMonthly'/*, '2'=>'AssetDepreciationOptionDurationTypeDaily'*/), 'validate'=>'1',),
|
||||
'rate' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionRate', 'enabled'=>'1', 'position'=>50, 'visible'=>3, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1', 'computed' => '$object->asset_depreciation_options->getRate("economic")',),
|
||||
'accelerated_depreciation_option' => array('type'=>'boolean', 'label'=>'AssetDepreciationOptionAcceleratedDepreciation', 'enabled'=>'1', 'position'=>60, 'column_break' => true, 'notnull'=>0, 'default'=>'0', 'visible'=>1, 'validate'=>'1',),
|
||||
'amount_base_depreciation_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDepreciationHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>90, 'notnull'=>0, 'required'=>1, 'visible'=>1, 'default'=>'$object->reversal_amount_ht > 0 ? $object->reversal_amount_ht : $object->acquisition_value_ht', 'isameasure'=>'1', 'validate'=>'1',),
|
||||
'amount_base_deductible_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDeductibleHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>100, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
|
||||
'total_amount_last_depreciation_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionTotalAmountLastDepreciationHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>110, 'noteditable'=> 1, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
|
||||
),
|
||||
),
|
||||
'accelerated_depreciation' => array(
|
||||
'label' => 'AssetDepreciationOptionAcceleratedDepreciation',
|
||||
'table' => 'asset_depreciation_options_fiscal',
|
||||
'enabled_field' => 'economic:accelerated_depreciation_option:1',
|
||||
'fields' => array(
|
||||
'depreciation_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDepreciationType', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDepreciationTypeLinear', '1'=>'AssetDepreciationOptionDepreciationTypeDegressive', '2'=>'AssetDepreciationOptionDepreciationTypeExceptional'), 'validate'=>'1',),
|
||||
'degressive_coefficient' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionDegressiveRate', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1','enabled_field' => 'accelerated_depreciation:depreciation_type:1'),
|
||||
'duration' => array('type'=>'integer', 'label'=>'AssetDepreciationOptionDuration', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
|
||||
'duration_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDurationType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDurationTypeAnnual', '1'=>'AssetDepreciationOptionDurationTypeMonthly'/*, '2'=>'AssetDepreciationOptionDurationTypeDaily'*/), 'validate'=>'1',),
|
||||
'rate' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionRate', 'enabled'=>'1', 'position'=>50, 'visible'=>3, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1', 'computed' => '$object->asset_depreciation_options->getRate("accelerated_depreciation")',),
|
||||
'amount_base_depreciation_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDepreciationHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>80, 'column_break' => true, 'notnull'=>0, 'required'=>1, 'visible'=>1, 'default'=>'$object->reversal_amount_ht > 0 ? $object->reversal_amount_ht : $object->acquisition_value_ht', 'isameasure'=>'1', 'validate'=>'1',),
|
||||
'amount_base_deductible_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDeductibleHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>90, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
|
||||
'total_amount_last_depreciation_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionTotalAmountLastDepreciationHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>100, 'noteditable'=> 1, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
|
||||
),
|
||||
),
|
||||
);
|
||||
public $fk_asset;
|
||||
public $fk_asset_model;
|
||||
public $tms;
|
||||
public $fk_user_modif;
|
||||
|
||||
/**
|
||||
* @var array Array with all deprecation options by mode.
|
||||
*/
|
||||
public $deprecation_options = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDb $db Database handler
|
||||
*/
|
||||
public function __construct(DoliDB $db)
|
||||
{
|
||||
global $langs;
|
||||
$this->db = $db;
|
||||
|
||||
// Translate some data of arrayofkeyval
|
||||
if (is_object($langs)) {
|
||||
foreach ($this->deprecation_options_fields as $mode_key => $mode_info) {
|
||||
if (!empty($mode_info['fields']) && is_array($mode_info['fields'])) {
|
||||
foreach ($mode_info['fields'] as $field_key => $field_info) {
|
||||
if (!empty($field_info['arrayofkeyval']) && is_array($field_info['arrayofkeyval'])) {
|
||||
foreach ($field_info['arrayofkeyval'] as $key => $val) {
|
||||
$this->deprecation_options_fields[$mode_key]['fields'][$field_key]['arrayofkeyval'][$key] = $langs->trans($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set object infos for a mode
|
||||
*
|
||||
* @param string $mode Depreciation mode (economic, accelerated_depreciation, ...)
|
||||
* @param int $class_type Type (0:asset, 1:asset model)
|
||||
* @param bool $all_field Get all fields
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function setInfosForMode($mode, $class_type = 0, $all_field = false)
|
||||
{
|
||||
// Clean parameters
|
||||
$mode = strtolower(trim($mode));
|
||||
|
||||
if (!empty($this->deprecation_options_fields[$mode])) {
|
||||
$this->table_element = $this->deprecation_options_fields[$mode]['table'];
|
||||
$this->fields = $this->deprecation_options_fields[$mode]['fields'];
|
||||
foreach ($this->fields as $field_key => $field_info) {
|
||||
if ((!empty($field_info['computed']) && !$all_field) || (!empty($field_info['only_on_asset']) && !empty($class_type))) {
|
||||
unset($this->fields[$field_key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Unset required option (notnull) if field disabled
|
||||
if (!empty($mode_info['enabled_field'])) {
|
||||
$info = explode(':', $mode_info['enabled_field']);
|
||||
if ($this->deprecation_options[$info[0]][$info[1]] != $info[2] && isset($this->fields[$field_key]['notnull'])) {
|
||||
unset($this->fields[$field_key]['notnull']);
|
||||
}
|
||||
}
|
||||
// Set value of the field in the object (for createCommon and setDeprecationOptionsFromPost functions)
|
||||
$this->{$field_key} = $this->deprecation_options[$mode][$field_key];
|
||||
}
|
||||
|
||||
$this->fields['rowid'] = array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id");
|
||||
if (empty($class_type)) {
|
||||
$this->fields['fk_asset'] = array('type' => 'integer:Asset:asset/class/asset.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label' => 'Asset', 'enabled' => '1', 'position' => 0, 'notnull' => 0, 'visible' => 0, 'index' => 1, 'validate' => '1',);
|
||||
} else {
|
||||
$this->fields['fk_asset_model'] = array('type' => 'integer:AssetModel:asset/class/assetmodel.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label' => 'AssetModel', 'enabled' => '1', 'position' => 0, 'notnull' => 0, 'visible' => 0, 'index' => 1, 'validate' => '1',);
|
||||
}
|
||||
$this->fields['tms'] = array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => '1', 'position' => 501, 'notnull' => 0, 'visible' => 0,);
|
||||
$this->fields['fk_user_modif'] = array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => '1', 'position' => 511, 'notnull' => -1, 'visible' => 0,);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill deprecation_options property of object (using for data sent by forms)
|
||||
*
|
||||
* @param int $class_type Type (0:asset, 1:asset model)
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function setDeprecationOptionsFromPost($class_type = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$error = 0;
|
||||
|
||||
$deprecation_options = array();
|
||||
foreach ($this->deprecation_options_fields as $mode_key => $mode_info) {
|
||||
$this->setInfosForMode($mode_key, $class_type);
|
||||
|
||||
foreach ($mode_info['fields'] as $field_key => $field_info) {
|
||||
if (!empty($field_info['computed'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$html_name = $mode_key . '_' . $field_key;
|
||||
if ($field_info['type'] == 'duration') {
|
||||
if (GETPOST($html_name . 'hour') == '' && GETPOST($html_name . 'min') == '') {
|
||||
continue; // The field was not submited to be saved
|
||||
}
|
||||
} else {
|
||||
if (!GETPOSTISSET($html_name)) {
|
||||
continue; // The field was not submited to be saved
|
||||
}
|
||||
}
|
||||
// Ignore special fields
|
||||
if (in_array($field_key, array('rowid', 'entity', 'import_key'))) {
|
||||
continue;
|
||||
}
|
||||
if (in_array($field_key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) {
|
||||
if (!in_array(abs($field_info['visible']), array(1, 3))) {
|
||||
continue; // Only 1 and 3 that are case to create
|
||||
}
|
||||
}
|
||||
|
||||
// Set value to insert
|
||||
if (in_array($field_info['type'], array('text', 'html'))) {
|
||||
$value = GETPOST($html_name, 'restricthtml');
|
||||
} elseif ($field_info['type'] == 'date') {
|
||||
$value = dol_mktime(12, 0, 0, GETPOST($html_name . 'month', 'int'), GETPOST($html_name . 'day', 'int'), GETPOST($html_name . 'year', 'int')); // for date without hour, we use gmt
|
||||
} elseif ($field_info['type'] == 'datetime') {
|
||||
$value = dol_mktime(GETPOST($html_name . 'hour', 'int'), GETPOST($html_name . 'min', 'int'), GETPOST($html_name . 'sec', 'int'), GETPOST($html_name . 'month', 'int'), GETPOST($html_name . 'day', 'int'), GETPOST($html_name . 'year', 'int'), 'tzuserrel');
|
||||
} elseif ($field_info['type'] == 'duration') {
|
||||
$value = 60 * 60 * GETPOST($html_name . 'hour', 'int') + 60 * GETPOST($html_name . 'min', 'int');
|
||||
} elseif (preg_match('/^(integer|price|real|double)/', $field_info['type'])) {
|
||||
$value = price2num(GETPOST($html_name, 'alphanohtml')); // To fix decimal separator according to lang setup
|
||||
} elseif ($field_info['type'] == 'boolean') {
|
||||
$value = ((GETPOST($html_name) == '1' || GETPOST($html_name) == 'on') ? 1 : 0);
|
||||
} elseif ($field_info['type'] == 'reference') {
|
||||
// todo to check
|
||||
$tmparraykey = array(); //array_keys($object->param_list);
|
||||
$value = $tmparraykey[GETPOST($html_name)] . ',' . GETPOST($html_name . '2');
|
||||
} else {
|
||||
if ($field_key == 'lang') {
|
||||
$value = GETPOST($html_name, 'aZ09') ? GETPOST($html_name, 'aZ09') : "";
|
||||
} else {
|
||||
$value = GETPOST($html_name, 'alphanohtml');
|
||||
}
|
||||
}
|
||||
if (preg_match('/^integer:/i', $field_info['type']) && $value == '-1') {
|
||||
$value = ''; // This is an implicit foreign key field
|
||||
}
|
||||
if (!empty($field_info['foreignkey']) && $value == '-1') {
|
||||
$value = ''; // This is an explicit foreign key field
|
||||
}
|
||||
|
||||
//var_dump($field_key.' '.$value.' '.$field_info['type']);
|
||||
$field_value = $value;
|
||||
if ($field_info['notnull'] > 0 && $field_value == '' && !is_null($field_info['default']) && $field_info['default'] == '(PROV)') {
|
||||
$field_value = '(PROV)';
|
||||
} elseif ((!empty($field_info['required']) || $field_info['notnull'] > 0) && $field_value == '' && !empty($field_info['default'])) {
|
||||
$field_value = dol_eval($field_info['default'], 1);
|
||||
}
|
||||
if ($field_info['notnull'] > 0 && $field_value == '' && is_null($field_info['default'])) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($field_info['label'])), null, 'errors');
|
||||
}
|
||||
$deprecation_options[$mode_key][$field_key] = $field_value;
|
||||
|
||||
// Validation of fields values
|
||||
if ($conf->global->MAIN_FEATURE_LEVEL >= 2 || !empty($conf->global->MAIN_ACTIVATE_VALIDATION_RESULT)) {
|
||||
if (!$error && !empty($field_info['validate']) && is_callable(array($this, 'validateField'))) {
|
||||
if (!$this->validateField($mode_info['fields'], $field_key, $value)) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Unset not enabled modes
|
||||
foreach ($this->deprecation_options_fields as $mode_key => $mode_info) {
|
||||
if (!empty($mode_info['enabled_field'])) {
|
||||
$info = explode(':', $mode_info['enabled_field']);
|
||||
if ($deprecation_options[$info[0]][$info[1]] != $info[2]) {
|
||||
unset($deprecation_options[$info[0]][$info[1]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->deprecation_options = $deprecation_options;
|
||||
|
||||
if ($error) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load deprecation options of a asset or a asset model
|
||||
*
|
||||
* @param int $asset_id Asset ID to set
|
||||
* @param int $asset_model_id Asset model ID to set
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetchDeprecationOptions($asset_id = 0, $asset_model_id = 0)
|
||||
{
|
||||
global $langs, $hookmanager;
|
||||
dol_syslog(__METHOD__ . " asset_id=$asset_id, asset_model_id=$asset_model_id");
|
||||
|
||||
$error = 0;
|
||||
$this->errors = array();
|
||||
$this->deprecation_options = array();
|
||||
|
||||
// Clean parameters
|
||||
$asset_id = $asset_id > 0 ? $asset_id : 0;
|
||||
$asset_model_id = $asset_model_id > 0 ? $asset_model_id : 0;
|
||||
|
||||
if (!is_object($hookmanager)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
|
||||
$hookmanager->initHooks(array('assetdepreciationoptionsdao'));
|
||||
$parameters = array('asset_id' => $asset_id, 'asset_model_id' => $asset_model_id);
|
||||
$reshook = $hookmanager->executeHooks('fetchDepreciationOptions', $parameters, $this); // Note that $action and $object may have been modified by some hooks
|
||||
if (!empty($reshook)) {
|
||||
return $reshook;
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
if (empty($asset_id) && empty($asset_model_id)) {
|
||||
$this->errors[] = $langs->trans('AssetErrorAssetOrAssetModelIDNotProvide');
|
||||
$error++;
|
||||
}
|
||||
if ($error) {
|
||||
dol_syslog(__METHOD__ . " Error check parameters: " . $this->errorsToString(), LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$class_type = $asset_id > 0 ? 0 : 1;
|
||||
$deprecation_options = array();
|
||||
foreach ($this->deprecation_options_fields as $mode_key => $mode_info) {
|
||||
$this->setInfosForMode($mode_key, $class_type);
|
||||
|
||||
$result = $this->fetchCommon(0, '', " AND " . ($asset_id > 0 ? " fk_asset = " . (int) $asset_id : " fk_asset_model = " . (int) $asset_model_id));
|
||||
if ($result < 0) {
|
||||
$this->errors = array_merge(array($langs->trans('AssetErrorFetchDepreciationOptionsForMode', $mode_key) . ':'), $this->errors);
|
||||
$error++;
|
||||
} elseif ($result > 0) {
|
||||
foreach ($this->fields as $field_key => $field_info) {
|
||||
if (in_array($field_key, array('rowid', 'fk_asset', 'fk_asset_model', 'tms', 'fk_user_modif'))) continue;
|
||||
$deprecation_options[$mode_key][$field_key] = $this->{$field_key};
|
||||
}
|
||||
}
|
||||
}
|
||||
// Unset not enabled modes
|
||||
foreach ($this->deprecation_options_fields as $mode_key => $mode_info) {
|
||||
if (!empty($mode_info['enabled_field'])) {
|
||||
$info = explode(':', $mode_info['enabled_field']);
|
||||
if ($deprecation_options[$info[0]][$info[1]] != $info[2]) {
|
||||
unset($deprecation_options[$info[0]][$info[1]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
dol_syslog(__METHOD__ . " Error fetch accountancy codes: " . $this->errorsToString(), LOG_ERR);
|
||||
return -1;
|
||||
} else {
|
||||
$this->deprecation_options = $deprecation_options;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get general depreciation info for a mode (used in depreciation card)
|
||||
*
|
||||
* @param string $mode Depreciation mode (economic, accelerated_depreciation, ...)
|
||||
* @return array|int <0 if KO otherwise array with general depreciation info
|
||||
*/
|
||||
public function getGeneralDepreciationInfoForMode($mode)
|
||||
{
|
||||
global $hookmanager;
|
||||
dol_syslog(__METHOD__ . " mode=$mode");
|
||||
|
||||
$this->errors = array();
|
||||
|
||||
// Clean parameters
|
||||
$mode = strtolower(trim($mode));
|
||||
|
||||
if (!is_object($hookmanager)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
|
||||
$hookmanager->initHooks(array('assetdepreciationoptionsdao'));
|
||||
$parameters = array('mode' => $mode);
|
||||
$reshook = $hookmanager->executeHooks('getGeneralDepreciationInfoForMode', $parameters, $this); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
return $reshook;
|
||||
} elseif ($reshook > 0) {
|
||||
return $hookmanager->resArray;
|
||||
}
|
||||
|
||||
$duration_type_list = $this->deprecation_options_fields[$mode]['fields']['duration_type']['arrayofkeyval'];
|
||||
|
||||
return array(
|
||||
'base_depreciation_ht' => $this->deprecation_options[$mode]['amount_base_depreciation_ht'],
|
||||
'duration' => $this->deprecation_options[$mode]['duration'],
|
||||
'duration_type' => $duration_type_list[$this->deprecation_options[$mode]['duration_type']],
|
||||
'rate' => $this->getRate($mode),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update deprecation options of a asset or a asset model
|
||||
*
|
||||
* @param User $user User making update
|
||||
* @param int $asset_id Asset ID to set
|
||||
* @param int $asset_model_id Asset model ID to set
|
||||
* @param int $notrigger 1=disable trigger UPDATE (when called by create)
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function updateDeprecationOptions($user, $asset_id = 0, $asset_model_id = 0, $notrigger = 0)
|
||||
{
|
||||
global $langs, $hookmanager;
|
||||
dol_syslog(__METHOD__ . " user_id={$user->id}, asset_id=$asset_id, asset_model_id=$asset_model_id, notrigger=$notrigger");
|
||||
|
||||
$error = 0;
|
||||
$this->errors = array();
|
||||
|
||||
// Clean parameters
|
||||
$asset_id = $asset_id > 0 ? $asset_id : 0;
|
||||
$asset_model_id = $asset_model_id > 0 ? $asset_model_id : 0;
|
||||
|
||||
if (!is_object($hookmanager)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
|
||||
$hookmanager->initHooks(array('assetdepreciationoptionsdao'));
|
||||
$parameters = array('user' => $user, 'asset_id' => $asset_id, 'asset_model_id' => $asset_model_id);
|
||||
$reshook = $hookmanager->executeHooks('updateDepreciationOptions', $parameters, $this); // Note that $action and $object may have been modified by some hooks
|
||||
if (!empty($reshook)) {
|
||||
return $reshook;
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
if (empty($asset_id) && empty($asset_model_id)) {
|
||||
$this->errors[] = $langs->trans('AssetErrorAssetOrAssetModelIDNotProvide');
|
||||
$error++;
|
||||
}
|
||||
if ($error) {
|
||||
dol_syslog(__METHOD__ . " Error check parameters: " . $this->errorsToString(), LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if ($asset_id > 0) {
|
||||
$this->fk_asset = $asset_id;
|
||||
$class_type = 0;
|
||||
} else {
|
||||
$this->fk_asset_model = $asset_model_id;
|
||||
$class_type = 1;
|
||||
}
|
||||
$this->tms = dol_now();
|
||||
$this->fk_user_modif = $user->id;
|
||||
|
||||
foreach ($this->deprecation_options_fields as $mode_key => $mode_info) {
|
||||
// Delete old accountancy codes
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . $mode_info['table'];
|
||||
$sql .= " WHERE " . ($asset_id > 0 ? " fk_asset = " . (int) $asset_id : " fk_asset_model = " . (int) $asset_model_id);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$this->errors[] = $langs->trans('AssetErrorDeleteDepreciationOptionsForMode', $mode_key) . ': ' . $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error && !empty($this->deprecation_options[$mode_key])) {
|
||||
if (!empty($mode_info['enabled_field'])) {
|
||||
$info = explode(':', $mode_info['enabled_field']);
|
||||
if ($this->deprecation_options[$info[0]][$info[1]] != $info[2]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->setInfosForMode($mode_key, $class_type);
|
||||
|
||||
$result = $this->createCommon($user, 1);
|
||||
if ($result < 0) {
|
||||
$this->errors = array_merge(array($langs->trans('AssetErrorInsertDepreciationOptionsForMode', $mode_key) . ':'), $this->errors);
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && $this->fk_asset > 0) {
|
||||
// Calculation of depreciation lines (reversal and future)
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php';
|
||||
$asset = new Asset($this->db);
|
||||
$result = $asset->fetch($this->fk_asset);
|
||||
if ($result > 0) $result = $asset->calculationDepreciation();
|
||||
if ($result < 0) {
|
||||
$this->errors[] = $langs->trans('AssetErrorCalculationDepreciationLines');
|
||||
$this->errors[] = $asset->errorsToString();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('ASSET_DEPRECIATION_OPTIONS_MODIFY', $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rate
|
||||
*
|
||||
* @param string $mode Depreciation mode (economic, accelerated_depreciation, ...)
|
||||
* @return string Rate of the provided mode option
|
||||
*/
|
||||
public function getRate($mode)
|
||||
{
|
||||
$duration = $this->deprecation_options[$mode]["duration"] > 0 ? $this->deprecation_options[$mode]["duration"] : 0;
|
||||
$duration_type = $this->deprecation_options[$mode]["duration_type"] > 0 ? $this->deprecation_options[$mode]["duration_type"] : 0;
|
||||
|
||||
return price(price2num($duration > 0 ? (100 * ($duration_type == 1 ? 12 : 1) / $duration) : 0, 2));
|
||||
}
|
||||
}
|
||||
822
htdocs/asset/class/assetmodel.class.php
Normal file
822
htdocs/asset/class/assetmodel.class.php
Normal file
@ -0,0 +1,822 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file class/assetmodel.class.php
|
||||
* \ingroup asset
|
||||
* \brief This file is a CRUD class file for AssetModel (Create/Read/Update/Delete)
|
||||
*/
|
||||
|
||||
// Put here all includes required by your class file
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
|
||||
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||
|
||||
/**
|
||||
* Class for AssetModel
|
||||
*/
|
||||
class AssetModel extends CommonObject
|
||||
{
|
||||
/**
|
||||
* @var string ID of module.
|
||||
*/
|
||||
public $module = 'asset';
|
||||
|
||||
/**
|
||||
* @var string ID to identify managed object.
|
||||
*/
|
||||
public $element = 'assetmodel';
|
||||
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
|
||||
*/
|
||||
public $table_element = 'asset_model';
|
||||
|
||||
/**
|
||||
* @var int Does this object support multicompany module ?
|
||||
* 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
|
||||
*/
|
||||
public $ismultientitymanaged = 1;
|
||||
|
||||
/**
|
||||
* @var int Does object support extrafields ? 0=No, 1=Yes
|
||||
*/
|
||||
public $isextrafieldmanaged = 1;
|
||||
|
||||
/**
|
||||
* @var string String with name of icon for assetmodel. Must be the part after the 'object_' into object_assetmodel.png
|
||||
*/
|
||||
public $picto = 'asset';
|
||||
|
||||
|
||||
const STATUS_DRAFT = 0;
|
||||
const STATUS_VALIDATED = 1;
|
||||
const STATUS_CANCELED = 9;
|
||||
|
||||
|
||||
/**
|
||||
* 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
|
||||
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
|
||||
* 'label' the translation key.
|
||||
* 'picto' is code of a picto to show before value in forms
|
||||
* 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)
|
||||
* 'position' is the sort order of field.
|
||||
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
|
||||
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
* 'noteditable' says if field is not editable (1 or 0)
|
||||
* 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
|
||||
* 'index' if we want an index in database.
|
||||
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
|
||||
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
|
||||
* 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage)
|
||||
* 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
|
||||
* 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
|
||||
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
|
||||
* 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
|
||||
* 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar'
|
||||
* 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
|
||||
* 'comment' is not used. You can store here any text of your choice. It is not used by application.
|
||||
* 'validate' is 1 if need to validate with $this->validateField()
|
||||
* 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value)
|
||||
*
|
||||
* Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
|
||||
*/
|
||||
public $fields=array(
|
||||
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
|
||||
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1'),
|
||||
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'showoncombobox'=>'2', 'validate'=>'1',),
|
||||
'asset_type' => array('type'=>'smallint', 'label'=>'AssetType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'arrayofkeyval'=>array('0'=>'AssetTypeIntangible', '1'=>'AssetTypeTangible', '2'=>'AssetTypeInProgress', '3'=>'AssetTypeFinancial'), 'validate'=>'1',),
|
||||
'fk_pays' =>array('type'=>'integer:Ccountry:core/class/ccountry.class.php', 'label'=>'Country', 'enabled'=>1, 'visible'=>1, 'position'=>50),
|
||||
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>300, 'notnull'=>0, 'visible'=>0, 'validate'=>'1',),
|
||||
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>301, 'notnull'=>0, 'visible'=>0, 'validate'=>'1',),
|
||||
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
|
||||
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
|
||||
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
|
||||
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
|
||||
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
|
||||
'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'default'=>'0', 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Enabled', '9'=>'Disabled'), 'validate'=>'1',),
|
||||
);
|
||||
public $rowid;
|
||||
public $ref;
|
||||
public $label;
|
||||
public $asset_type;
|
||||
public $note_public;
|
||||
public $note_private;
|
||||
public $date_creation;
|
||||
public $tms;
|
||||
public $fk_user_creat;
|
||||
public $fk_user_modif;
|
||||
public $last_main_doc;
|
||||
public $import_key;
|
||||
public $model_pdf;
|
||||
public $status;
|
||||
|
||||
// /**
|
||||
// * @var string Field with ID of parent key if this object has a parent
|
||||
// */
|
||||
// public $fk_element = 'fk_assetmodel';
|
||||
// /**
|
||||
// * @var array List of child tables. To test if we can delete object.
|
||||
// */
|
||||
// protected $childtables = array();
|
||||
// /**
|
||||
// * @var array List of child tables. To know object to delete on cascade.
|
||||
// * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
|
||||
// * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
|
||||
// */
|
||||
// protected $childtablesoncascade = array('asset_assetmodeldet');
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDb $db Database handler
|
||||
*/
|
||||
public function __construct(DoliDB $db)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$this->db = $db;
|
||||
|
||||
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
|
||||
$this->fields['rowid']['visible'] = 0;
|
||||
}
|
||||
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
|
||||
$this->fields['entity']['enabled'] = 0;
|
||||
}
|
||||
|
||||
// Unset fields that are disabled
|
||||
foreach ($this->fields as $key => $val) {
|
||||
if (isset($val['enabled']) && empty($val['enabled'])) {
|
||||
unset($this->fields[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// Translate some data of arrayofkeyval
|
||||
if (is_object($langs)) {
|
||||
foreach ($this->fields as $key => $val) {
|
||||
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
|
||||
foreach ($val['arrayofkeyval'] as $key2 => $val2) {
|
||||
$this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create object into database
|
||||
*
|
||||
* @param User $user User that creates
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, Id of created object if OK
|
||||
*/
|
||||
public function create(User $user, $notrigger = false)
|
||||
{
|
||||
$resultcreate = $this->createCommon($user, $notrigger);
|
||||
|
||||
return $resultcreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone an object into another one
|
||||
*
|
||||
* @param User $user User that creates
|
||||
* @param int $fromid Id of object to clone
|
||||
* @return mixed New object created, <0 if KO
|
||||
*/
|
||||
public function createFromClone(User $user, $fromid)
|
||||
{
|
||||
global $langs, $extrafields;
|
||||
$error = 0;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$object = new self($this->db);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Load source object
|
||||
$result = $object->fetchCommon($fromid);
|
||||
if ($result > 0 && !empty($object->table_element_line)) {
|
||||
$object->fetchLines();
|
||||
}
|
||||
|
||||
// get lines so they will be clone
|
||||
//foreach($this->lines as $line)
|
||||
// $line->fetch_optionals();
|
||||
|
||||
// Reset some properties
|
||||
unset($object->id);
|
||||
unset($object->fk_user_creat);
|
||||
unset($object->import_key);
|
||||
|
||||
// Clear fields
|
||||
if (property_exists($object, 'ref')) {
|
||||
$object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
|
||||
}
|
||||
if (property_exists($object, 'label')) {
|
||||
$object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
|
||||
}
|
||||
if (property_exists($object, 'status')) {
|
||||
$object->status = self::STATUS_DRAFT;
|
||||
}
|
||||
if (property_exists($object, 'date_creation')) {
|
||||
$object->date_creation = dol_now();
|
||||
}
|
||||
if (property_exists($object, 'date_modification')) {
|
||||
$object->date_modification = null;
|
||||
}
|
||||
// ...
|
||||
// Clear extrafields that are unique
|
||||
if (is_array($object->array_options) && count($object->array_options) > 0) {
|
||||
$extrafields->fetch_name_optionals_label($this->table_element);
|
||||
foreach ($object->array_options as $key => $option) {
|
||||
$shortkey = preg_replace('/options_/', '', $key);
|
||||
if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
|
||||
//var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
|
||||
unset($object->array_options[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create clone
|
||||
$object->context['createfromclone'] = 'createfromclone';
|
||||
$result = $object->createCommon($user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$this->error = $object->error;
|
||||
$this->errors = $object->errors;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// copy internal contacts
|
||||
if ($this->copy_linked_contact($object, 'internal') < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// copy external contacts if same company
|
||||
if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
|
||||
if ($this->copy_linked_contact($object, 'external') < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($object->context['createfromclone']);
|
||||
|
||||
// End
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return $object;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load object in memory from the database
|
||||
*
|
||||
* @param int $id Id object
|
||||
* @param string $ref Ref
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
public function fetch($id, $ref = null)
|
||||
{
|
||||
$result = $this->fetchCommon($id, $ref);
|
||||
if ($result > 0 && !empty($this->table_element_line)) {
|
||||
$this->fetchLines();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load object lines in memory from the database
|
||||
*
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
public function fetchLines()
|
||||
{
|
||||
$this->lines = array();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load list of objects in memory from the database.
|
||||
*
|
||||
* @param string $sortorder Sort Order
|
||||
* @param string $sortfield Sort field
|
||||
* @param int $limit limit
|
||||
* @param int $offset Offset
|
||||
* @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...)
|
||||
* @param string $filtermode Filter mode (AND or OR)
|
||||
* @return array|int int <0 if KO, array of pages if OK
|
||||
*/
|
||||
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$records = array();
|
||||
|
||||
$sql = "SELECT ";
|
||||
$sql .= $this->getFieldList('t');
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
|
||||
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
|
||||
$sql .= " WHERE t.entity IN (".getEntity($this->table_element).")";
|
||||
} else {
|
||||
$sql .= " WHERE 1 = 1";
|
||||
}
|
||||
// Manage filter
|
||||
$sqlwhere = array();
|
||||
if (count($filter) > 0) {
|
||||
foreach ($filter as $key => $value) {
|
||||
if ($key == 't.rowid') {
|
||||
$sqlwhere[] = $key." = ".((int) $value);
|
||||
} elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
|
||||
$sqlwhere[] = $key." = '".$this->db->idate($value)."'";
|
||||
} elseif ($key == 'customsql') {
|
||||
$sqlwhere[] = $value;
|
||||
} elseif (strpos($value, '%') === false) {
|
||||
$sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
|
||||
} else {
|
||||
$sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")";
|
||||
}
|
||||
|
||||
if (!empty($sortfield)) {
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($limit)) {
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < ($limit ? min($limit, $num) : $num)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$record = new self($this->db);
|
||||
$record->setVarsFromFetchObj($obj);
|
||||
|
||||
$records[$record->id] = $record;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
return $records;
|
||||
} else {
|
||||
$this->errors[] = 'Error '.$this->db->lasterror();
|
||||
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update object into database
|
||||
*
|
||||
* @param User $user User that modifies
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function update(User $user, $notrigger = false)
|
||||
{
|
||||
return $this->updateCommon($user, $notrigger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete object in database
|
||||
*
|
||||
* @param User $user User that deletes
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete(User $user, $notrigger = false)
|
||||
{
|
||||
return $this->deleteCommon($user, $notrigger);
|
||||
//return $this->deleteCommon($user, $notrigger, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate object
|
||||
*
|
||||
* @param User $user User making status change
|
||||
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
||||
* @return int <=0 if OK, 0=Nothing done, >0 if KO
|
||||
*/
|
||||
public function validate($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$error = 0;
|
||||
|
||||
// Protection
|
||||
if ($this->status == self::STATUS_VALIDATED) {
|
||||
dol_syslog(get_class($this) . "::validate action abandonned: already validated", LOG_WARNING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Validate
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element;
|
||||
$sql .= " SET status = " . self::STATUS_VALIDATED;
|
||||
if (!empty($this->fields['date_validation'])) {
|
||||
$sql .= ", date_validation = '" . $this->db->idate($now) . "'";
|
||||
}
|
||||
if (!empty($this->fields['fk_user_valid'])) {
|
||||
$sql .= ", fk_user_valid = " . ((int) $user->id);
|
||||
}
|
||||
$sql .= " WHERE rowid = " . ((int) $this->id);
|
||||
|
||||
dol_syslog(get_class($this) . "::validate()", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
dol_print_error($this->db);
|
||||
$this->error = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('ASSETMODEL_VALIDATE', $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
// Set new ref and current status
|
||||
if (!$error) {
|
||||
$this->status = self::STATUS_VALIDATED;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set draft status
|
||||
*
|
||||
* @param User $user Object user that modify
|
||||
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function setDraft($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status <= self::STATUS_DRAFT) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'ASSETMODEL_UNVALIDATE');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cancel status
|
||||
*
|
||||
* @param User $user Object user that modify
|
||||
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
|
||||
* @return int <0 if KO, 0=Nothing done, >0 if OK
|
||||
*/
|
||||
public function cancel($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status != self::STATUS_VALIDATED) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'ASSETMODEL_CANCEL');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set back to validated status
|
||||
*
|
||||
* @param User $user Object user that modify
|
||||
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
|
||||
* @return int <0 if KO, 0=Nothing done, >0 if OK
|
||||
*/
|
||||
public function reopen($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status != self::STATUS_CANCELED) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'ASSETMODEL_REOPEN');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a link to the object card (with optionaly the picto)
|
||||
*
|
||||
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
|
||||
* @param string $option On what the link point to ('nolink', ...)
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param string $morecss Add more css on link
|
||||
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
|
||||
* @return string String with URL
|
||||
*/
|
||||
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
|
||||
{
|
||||
global $conf, $langs, $hookmanager;
|
||||
|
||||
if (!empty($conf->dol_no_mouse_hover)) {
|
||||
$notooltip = 1; // Force disable tooltips
|
||||
}
|
||||
|
||||
$result = '';
|
||||
|
||||
$label = img_picto('', $this->picto).' <u>'.$langs->trans("AssetModel").'</u>';
|
||||
if (isset($this->status)) {
|
||||
$label .= ' '.$this->getLibStatut(5);
|
||||
}
|
||||
$label .= '<br>';
|
||||
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
||||
|
||||
$url = dol_buildpath('/asset/model/card.php', 1).'?id='.$this->id;
|
||||
|
||||
if ($option != 'nolink') {
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
|
||||
$add_save_lastsearch_values = 1;
|
||||
}
|
||||
if ($add_save_lastsearch_values) {
|
||||
$url .= '&save_lastsearch_values=1';
|
||||
}
|
||||
}
|
||||
|
||||
$linkclose = '';
|
||||
if (empty($notooltip)) {
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
$label = $langs->trans("ShowAssetModel");
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
|
||||
} else {
|
||||
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
}
|
||||
|
||||
if ($option == 'nolink') {
|
||||
$linkstart = '<span';
|
||||
} else {
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
}
|
||||
$linkstart .= $linkclose.'>';
|
||||
if ($option == 'nolink') {
|
||||
$linkend = '</span>';
|
||||
} else {
|
||||
$linkend = '</a>';
|
||||
}
|
||||
|
||||
$result .= $linkstart;
|
||||
|
||||
if (empty($this->showphoto_on_popup)) {
|
||||
if ($withpicto) {
|
||||
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
} else {
|
||||
if ($withpicto) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
list($class, $module) = explode('@', $this->picto);
|
||||
$upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
|
||||
$filearray = dol_dir_list($upload_dir, "files");
|
||||
$filename = $filearray[0]['name'];
|
||||
if (!empty($filename)) {
|
||||
$pospoint = strpos($filearray[0]['name'], '.');
|
||||
|
||||
$pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
|
||||
if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
|
||||
$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.'" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div></div>';
|
||||
} else {
|
||||
$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div>';
|
||||
}
|
||||
|
||||
$result .= '</div>';
|
||||
} else {
|
||||
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($withpicto != 2) {
|
||||
$result .= $this->ref;
|
||||
}
|
||||
|
||||
$result .= $linkend;
|
||||
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
|
||||
|
||||
global $action, $hookmanager;
|
||||
$hookmanager->initHooks(array('assetmodeldao'));
|
||||
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
|
||||
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook > 0) {
|
||||
$result = $hookmanager->resPrint;
|
||||
} else {
|
||||
$result .= $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the label of the status
|
||||
*
|
||||
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
|
||||
* @return string Label of status
|
||||
*/
|
||||
public function getLabelStatus($mode = 0)
|
||||
{
|
||||
return $this->LibStatut($this->status, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the label of the status
|
||||
*
|
||||
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
|
||||
* @return string Label of status
|
||||
*/
|
||||
public function getLibStatut($mode = 0)
|
||||
{
|
||||
return $this->LibStatut($this->status, $mode);
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return the status
|
||||
*
|
||||
* @param int $status Id status
|
||||
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
|
||||
* @return string Label of status
|
||||
*/
|
||||
public function LibStatut($status, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||
global $langs;
|
||||
//$langs->load("asset@asset");
|
||||
$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
|
||||
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
|
||||
$this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
|
||||
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
|
||||
$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
|
||||
$this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
|
||||
}
|
||||
|
||||
$statusType = 'status'.$status;
|
||||
//if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
|
||||
if ($status == self::STATUS_CANCELED) {
|
||||
$statusType = 'status6';
|
||||
}
|
||||
|
||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the info information in the object
|
||||
*
|
||||
* @param int $id Id of object
|
||||
* @return void
|
||||
*/
|
||||
public function info($id)
|
||||
{
|
||||
$sql = "SELECT rowid, date_creation as datec, tms as datem,";
|
||||
$sql .= " fk_user_creat, fk_user_modif";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
|
||||
$sql .= " WHERE t.rowid = ".((int) $id);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
if ($this->db->num_rows($result)) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
if ($obj->fk_user_author) {
|
||||
$cuser = new User($this->db);
|
||||
$cuser->fetch($obj->fk_user_author);
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
|
||||
if ($obj->fk_user_valid) {
|
||||
$vuser = new User($this->db);
|
||||
$vuser->fetch($obj->fk_user_valid);
|
||||
$this->user_validation = $vuser;
|
||||
}
|
||||
|
||||
if ($obj->fk_user_cloture) {
|
||||
$cluser = new User($this->db);
|
||||
$cluser->fetch($obj->fk_user_cloture);
|
||||
$this->user_cloture = $cluser;
|
||||
}
|
||||
|
||||
$this->date_creation = $this->db->jdate($obj->datec);
|
||||
$this->date_modification = $this->db->jdate($obj->datem);
|
||||
$this->date_validation = $this->db->jdate($obj->datev);
|
||||
}
|
||||
|
||||
$this->db->free($result);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise object with example values
|
||||
* Id must be 0 if object instance is a specimen
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initAsSpecimen()
|
||||
{
|
||||
// Set here init that are not commonf fields
|
||||
// $this->property1 = ...
|
||||
// $this->property2 = ...
|
||||
|
||||
$this->initAsSpecimenCommon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an array of lines
|
||||
*
|
||||
* @return array|int array of lines if OK, <0 if KO
|
||||
*/
|
||||
public function getLinesArray()
|
||||
{
|
||||
$this->lines = array();
|
||||
|
||||
return $this->lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action executed by scheduler
|
||||
* CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters'
|
||||
* Use public function doScheduledJob($param1, $param2, ...) to get parameters
|
||||
*
|
||||
* @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
|
||||
*/
|
||||
public function doScheduledJob()
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
//$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
|
||||
|
||||
$error = 0;
|
||||
$this->output = '';
|
||||
$this->error = '';
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// ...
|
||||
|
||||
$this->db->commit();
|
||||
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
199
htdocs/asset/depreciation.php
Normal file
199
htdocs/asset/depreciation.php
Normal file
@ -0,0 +1,199 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/depreciation.php
|
||||
* \ingroup asset
|
||||
* \brief Card with depreciation on Asset
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetdepreciationoptions.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("assets", "companies"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new Asset($db);
|
||||
$assetdepreciationoptions = new AssetDepreciationOptions($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('assetdepreciation', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
|
||||
}
|
||||
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
if (!empty($object->not_depreciated)) accessforbidden();
|
||||
|
||||
$object->asset_depreciation_options = &$assetdepreciationoptions;
|
||||
$result = $assetdepreciationoptions->fetchDeprecationOptions($object->id);
|
||||
if ($result < 0) {
|
||||
setEventMessages($assetdepreciationoptions->error, $assetdepreciationoptions->errors, 'errors');
|
||||
}
|
||||
$result = $object->fetchDepreciationLines();
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
if (empty($reshook)) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$help_url = '';
|
||||
llxHeader('', $langs->trans('Asset'), $help_url);
|
||||
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$head = assetPrepareHead($object);
|
||||
print dol_get_fiche_head($head, 'depreciation', $langs->trans("Asset"), -1, $object->picto);
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/asset/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('listAssetDeprecation', $parameters, $object, $action);
|
||||
print $hookmanager->resPrint;
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
} elseif (empty($reshook)) {
|
||||
$bookkeeping_icon = '<i class="fas fa-save" title="'.$langs->trans('AssetDispatchedInBookkeeping').'"></i>';
|
||||
$future_icon = '<i class="fas fa-clock" title="'.$langs->trans('AssetFutureDepreciationLine').'"></i>';
|
||||
$now = dol_now();
|
||||
|
||||
foreach ($assetdepreciationoptions->deprecation_options_fields as $mode_key => $fields) {
|
||||
$lines = $object->depreciation_lines[$mode_key];
|
||||
if (!empty($lines)) {
|
||||
$mode_info = $assetdepreciationoptions->deprecation_options_fields[$mode_key];
|
||||
$depreciation_info = $assetdepreciationoptions->getGeneralDepreciationInfoForMode($mode_key);
|
||||
|
||||
print load_fiche_titre($langs->trans($mode_info['label']), '', '');
|
||||
|
||||
// Depreciation general info
|
||||
//---------------------------------
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">' . "\n";
|
||||
print '<tr><td class="titlefield">' . $langs->trans('AssetBaseDepreciationHT') . '</td><td>' . price($depreciation_info['base_depreciation_ht']) . '</td></tr>';
|
||||
print '<tr><td class="titlefield">' . $langs->trans('AssetDepreciationBeginDate') . '</td><td>' . dol_print_date($object->date_start > $object->date_acquisition ? $object->date_start : $object->date_acquisition, 'day') . '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
// We close div and reopen for second column
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
print '<tr><td class="titlefield">' . $langs->trans('AssetDepreciationDuration') . '</td><td>' . $depreciation_info['duration'] . ' ( ' . $depreciation_info['duration_type'] . ' )</td></tr>';
|
||||
print '<tr><td class="titlefield">' . $langs->trans('AssetDepreciationRate') . '</td><td>' . $depreciation_info['rate'] . '</td></tr>';
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
print '<div class="clearboth"></div>';
|
||||
|
||||
// Depreciation lines
|
||||
//---------------------------------
|
||||
print '<br>';
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder allwidth">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="width20"></td>';
|
||||
print '<td>' . $langs->trans("Ref") . '</td>';
|
||||
print '<td class="center">' . $langs->trans("AssetDepreciationDate") . '</td>';
|
||||
print '<td class="right">' . $langs->trans("AssetDepreciationHT") . '</td>';
|
||||
print '<td class="right">' . $langs->trans("AssetCumulativeDepreciationHT") . '</td>';
|
||||
print '<td class="right">' . $langs->trans("AssetResidualHT") . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
if (empty($lines)) {
|
||||
print '<tr><td class="impair center" colspan="6"><span class="opacitymedium">' . $langs->trans("None") . '</span></td></tr>';
|
||||
} else {
|
||||
foreach ($lines as $line) {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>' . ($line['bookkeeping'] ? $bookkeeping_icon : ($line['depreciation_date'] > $now ? $future_icon : '')) . '</td>';
|
||||
print '<td >' . (empty($line['ref']) ? $langs->trans('AssetDepreciationReversal') : $line['ref']) . '</td>';
|
||||
print '<td class="center">' . dol_print_date($line['depreciation_date'], 'day') . '</td>';
|
||||
print '<td class="right">';
|
||||
print price($line['depreciation_ht']);
|
||||
print '</td>';
|
||||
print '<td class="right">';
|
||||
print price($line['cumulative_depreciation_ht']);
|
||||
print '</td>';
|
||||
print '<td class="right">';
|
||||
print price(price2num($depreciation_info['base_depreciation_ht'] - $line['cumulative_depreciation_ht'], 'MT'));
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
190
htdocs/asset/depreciation_options.php
Normal file
190
htdocs/asset/depreciation_options.php
Normal file
@ -0,0 +1,190 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/depreciation_options.php
|
||||
* \ingroup asset
|
||||
* \brief Card with depreciation options on Asset
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetdepreciationoptions.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("assets", "companies"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new Asset($db);
|
||||
$assetdepreciationoptions = new AssetDepreciationOptions($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('assetdepreciationoptions', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
|
||||
}
|
||||
|
||||
$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php
|
||||
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
if (!empty($object->not_depreciated)) accessforbidden();
|
||||
|
||||
$object->asset_depreciation_options = &$assetdepreciationoptions;
|
||||
$result = $assetdepreciationoptions->fetchDeprecationOptions($object->id);
|
||||
if ($result < 0) {
|
||||
setEventMessages($assetdepreciationoptions->error, $assetdepreciationoptions->errors, 'errors');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
if (empty($reshook)) {
|
||||
$backurlforlist = DOL_URL_ROOT.'/asset/list.php';
|
||||
|
||||
if (empty($backtopage) || ($cancel && empty($id))) {
|
||||
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
|
||||
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
|
||||
$backtopage = $backurlforlist;
|
||||
} else {
|
||||
$backtopage = DOL_URL_ROOT.'/asset/depreciation_options.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($cancel) {
|
||||
/*var_dump($cancel);var_dump($backtopage);var_dump($backtopageforcancel);exit;*/
|
||||
if (!empty($backtopageforcancel)) {
|
||||
header("Location: ".$backtopageforcancel);
|
||||
exit;
|
||||
} elseif (!empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
$action = '';
|
||||
}
|
||||
|
||||
if ($action == "update") {
|
||||
$result = $assetdepreciationoptions->setDeprecationOptionsFromPost();
|
||||
if ($result > 0) $result = $assetdepreciationoptions->updateDeprecationOptions($user, $object->id);
|
||||
if ($result < 0) {
|
||||
setEventMessages($assetdepreciationoptions->error, $assetdepreciationoptions->errors, 'errors');
|
||||
$action = 'edit';
|
||||
} else {
|
||||
setEventMessage($langs->trans('RecordSaved'));
|
||||
header("Location: " . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$help_url = '';
|
||||
llxHeader('', $langs->trans('Asset'), $help_url);
|
||||
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$head = assetPrepareHead($object);
|
||||
print dol_get_fiche_head($head, 'depreciation_options', $langs->trans("Asset"), -1, $object->picto);
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/asset/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '</div>';
|
||||
|
||||
if ($action == 'edit') {
|
||||
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '">';
|
||||
print '<input type="hidden" name="token" value="' . newToken() . '">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
if ($backtopage) {
|
||||
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
|
||||
}
|
||||
if ($backtopageforcancel) {
|
||||
print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
|
||||
}
|
||||
|
||||
print dol_get_fiche_head(array(), '');
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/asset/tpl/depreciation_options_edit.tpl.php';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print $form->buttonsSaveCancel();
|
||||
|
||||
print '</form>';
|
||||
} else {
|
||||
include DOL_DOCUMENT_ROOT . '/asset/tpl/depreciation_options_view.tpl.php';
|
||||
}
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
if ($action != 'edit') {
|
||||
print '<div class="tabsAction">' . "\n";
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
if ($object->status == $object::STATUS_DRAFT/* && !empty($object->enabled_modes)*/) {
|
||||
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit&token=' . newToken(), '', $permissiontoadd);
|
||||
}
|
||||
}
|
||||
print '</div>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
120
htdocs/asset/disposal.php
Normal file
120
htdocs/asset/disposal.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/disposal.php
|
||||
* \ingroup asset
|
||||
* \brief Card with disposal info on Asset
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("assets", "companies"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new Asset($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('assetdisposal', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$upload_dir = $conf->asset->multidir_output[$object->entity]."/".$object->id;
|
||||
}
|
||||
|
||||
$permissionnote = $user->rights->asset->write; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php
|
||||
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
if (!isset($object->disposal_date) || $object->disposal_date === "") accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
if (empty($reshook)) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$help_url = '';
|
||||
llxHeader('', $langs->trans('Asset'), $help_url);
|
||||
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$head = assetPrepareHead($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'disposal', $langs->trans("Asset"), -1, $object->picto);
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/asset/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">'."\n";
|
||||
|
||||
// Common attributes
|
||||
$show_fields = array('disposal_date', 'disposal_amount_ht', 'fk_disposal_type', 'disposal_depreciated', 'disposal_subject_to_vat');
|
||||
foreach ($object->fields as $field_key => $field_info) {
|
||||
$object->fields[$field_key]['visible'] = in_array($field_key, $show_fields) ? 1 : 0;
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -31,19 +31,18 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('assets', 'companies', 'other'));
|
||||
$langs->loadLangs(array('assets', 'companies', 'other', 'mails'));
|
||||
|
||||
|
||||
$id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$socid = GETPOST('socid', 'int');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
|
||||
// Get parameters
|
||||
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
@ -58,18 +57,28 @@ if (!$sortfield) {
|
||||
$sortfield = "name";
|
||||
}
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new Asset($db);
|
||||
if ($object->fetch($id)) {
|
||||
$upload_dir = $conf->asset->dir_output."/".dol_sanitizeFileName($object->ref);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('assetdocument', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$upload_dir = $conf->asset->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object);
|
||||
}
|
||||
|
||||
$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
|
||||
$permissiontoadd = $user->rights->asset->asset->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
|
||||
|
||||
// Security check
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result=restrictedArea($user, 'asset', $id, '');
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
@ -83,60 +92,67 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
|
||||
* View
|
||||
*/
|
||||
|
||||
$title = $langs->trans('Assets')." - ".$langs->trans('Documents');
|
||||
|
||||
$help_url = '';
|
||||
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$title = $langs->trans("Asset").' - '.$langs->trans("Files");
|
||||
$help_url = '';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if ($object->id) {
|
||||
/*
|
||||
* Show tabs
|
||||
*/
|
||||
$head = assetPrepareHead($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'document', $langs->trans("Asset"), -1, $object->picto);
|
||||
|
||||
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
if ($object->fetch($id, $ref) > 0) {
|
||||
$upload_dir = $conf->asset->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
|
||||
|
||||
$head = asset_prepare_head($object);
|
||||
print dol_get_fiche_head($head, 'documents', $langs->trans('Asset'), -1, 'accounting');
|
||||
|
||||
// Build file list
|
||||
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
|
||||
$totalsize = 0;
|
||||
foreach ($filearray as $key => $file) {
|
||||
$totalsize += $file['size'];
|
||||
}
|
||||
|
||||
// Asset content
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/asset/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref = '';
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border tableforfield centpercent">';
|
||||
|
||||
print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
|
||||
print "</table>\n";
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
$modulepart = 'asset';
|
||||
$permissiontoadd = $user->rights->asset->write;
|
||||
$permtoedit = $user->rights->asset->write;
|
||||
$param = '&id='.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
// Build file list
|
||||
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
|
||||
$totalsize = 0;
|
||||
foreach ($filearray as $key => $file) {
|
||||
$totalsize += $file['size'];
|
||||
}
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' . dol_buildpath('/asset/asset_list.php', 1) . '?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
// Number of files
|
||||
print '<tr><td class="titlefield">' . $langs->trans("NbOfAttachedFiles") . '</td><td colspan="3">' . count($filearray) . '</td></tr>';
|
||||
|
||||
// Total size
|
||||
print '<tr><td>' . $langs->trans("TotalSizeOfAttachedFiles") . '</td><td colspan="3">' . $totalsize . ' ' . $langs->trans("bytes") . '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
$modulepart = 'asset';
|
||||
$permissiontoadd = $user->rights->asset->write;
|
||||
// $permissiontoadd = 1;
|
||||
$permtoedit = $user->rights->asset->write;
|
||||
// $permtoedit = 1;
|
||||
$param = '&id=' . $object->id;
|
||||
|
||||
//$relativepathwithnofile='asset/' . dol_sanitizeFileName($object->id).'/';
|
||||
$relativepathwithnofile = dol_sanitizeFileName($object->ref) . '/';
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
|
||||
} else {
|
||||
print $langs->trans("ErrorUnknown");
|
||||
accessforbidden('', 0, 1);
|
||||
}
|
||||
|
||||
// End of page
|
||||
|
||||
@ -1,93 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/info.php
|
||||
* \ingroup asset
|
||||
* \brief Page to show an asset information
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("asset"));
|
||||
|
||||
$id = GETPOSTINT('id');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
// Security check
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'asset', $id);
|
||||
|
||||
$object = new Asset($db);
|
||||
$object->fetch($id);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// None
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$title = $langs->trans('Asset')." - ".$langs->trans('Info');
|
||||
|
||||
$help_url = "";
|
||||
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
$object->info($id);
|
||||
|
||||
$head = asset_prepare_head($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'info', $langs->trans("Asset"), -1, 'generic');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table width="100%"><tr><td>';
|
||||
dol_print_object_info($object);
|
||||
print '</td></tr></table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -31,26 +31,26 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("assets"));
|
||||
$langs->loadLangs(array("assets", "other"));
|
||||
|
||||
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
|
||||
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
|
||||
$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
|
||||
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
|
||||
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
|
||||
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'assetlist'; // To manage different context of search
|
||||
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
||||
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
||||
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
|
||||
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
|
||||
$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
|
||||
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
|
||||
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
|
||||
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'assetlist'; // To manage different context of search
|
||||
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
||||
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
||||
|
||||
$id = GETPOST('id', 'int');
|
||||
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
|
||||
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||
$offset = $limit * $page;
|
||||
@ -71,33 +71,24 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
|
||||
|
||||
// Default sort order (if not yet defined by previous GETPOST)
|
||||
if (!$sortfield) {
|
||||
reset($object->fields); // Reset is required to avoid key() to return null.
|
||||
$sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
|
||||
// Security check
|
||||
$socid = 0;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
if ($user->socid > 0) {
|
||||
// Protection if external user
|
||||
//$socid = $user->socid;
|
||||
accessforbidden();
|
||||
}
|
||||
// Security check
|
||||
$result = restrictedArea($user, 'asset', $id);
|
||||
|
||||
|
||||
// Initialize array of search criterias
|
||||
$search_all = GETPOST("search_all", 'alpha');
|
||||
$search_all = GETPOST('search_all', 'alphanohtml');
|
||||
$search = array();
|
||||
foreach ($object->fields as $key => $val) {
|
||||
if (GETPOST('search_'.$key, 'alpha') !== '') {
|
||||
$search[$key] = GETPOST('search_'.$key, 'alpha');
|
||||
}
|
||||
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
||||
$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
|
||||
$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
|
||||
}
|
||||
}
|
||||
|
||||
// List of fields to search into when doing a "search in all"
|
||||
@ -108,27 +99,24 @@ foreach ($object->fields as $key => $val) {
|
||||
}
|
||||
}
|
||||
|
||||
// Definition of fields for list
|
||||
// Definition of array of fields for columns
|
||||
$arrayfields = array();
|
||||
foreach ($object->fields as $key => $val) {
|
||||
// If $val['visible']==0, then we never show the field
|
||||
if (!empty($val['visible'])) {
|
||||
$arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']);
|
||||
$visible = (int) dol_eval($val['visible'], 1);
|
||||
$arrayfields['t.'.$key] = array(
|
||||
'label'=>$val['label'],
|
||||
'checked'=>(($visible < 0) ? 0 : 1),
|
||||
'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
|
||||
'position'=>$val['position'],
|
||||
'help'=> isset($val['help']) ? $val['help'] : ''
|
||||
);
|
||||
}
|
||||
}
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
|
||||
$arrayfields["ef.".$key] = array(
|
||||
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
|
||||
'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
|
||||
'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
|
||||
'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
@ -136,13 +124,28 @@ $permissiontoread = $user->rights->asset->read;
|
||||
$permissiontoadd = $user->rights->asset->write;
|
||||
$permissiontodelete = $user->rights->asset->delete;
|
||||
|
||||
// Security check
|
||||
if (empty($conf->asset->enabled)) {
|
||||
accessforbidden('Module not enabled');
|
||||
}
|
||||
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
$socid = 0; if ($user->socid > 0) $socid = $user->socid;
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$action = 'list'; $massaction = '';
|
||||
$action = 'list';
|
||||
$massaction = '';
|
||||
}
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||
$massaction = '';
|
||||
@ -162,8 +165,12 @@ if (empty($reshook)) {
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$search[$key] = '';
|
||||
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
||||
$search[$key.'_dtstart'] = '';
|
||||
$search[$key.'_dtend'] = '';
|
||||
}
|
||||
}
|
||||
$toselect = '';
|
||||
$toselect = array();
|
||||
$search_array_options = array();
|
||||
}
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|
||||
@ -188,21 +195,20 @@ $form = new Form($db);
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
//$help_url="EN:Module_Asset|FR:Module_Asset_FR|ES:Módulo_Asset";
|
||||
$help_url = '';
|
||||
$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Assets"));
|
||||
$morejs = array();
|
||||
$morecss = array();
|
||||
|
||||
|
||||
// Build and execute select
|
||||
// --------------------------------------------------------------------
|
||||
$sql = 'SELECT ';
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$sql .= "t.".$key.", ";
|
||||
}
|
||||
$sql .= $object->getFieldList('t');
|
||||
// Add fields from extrafields
|
||||
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : '');
|
||||
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
|
||||
}
|
||||
}
|
||||
// Add fields from hooks
|
||||
@ -211,27 +217,45 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje
|
||||
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
|
||||
$sql = preg_replace('/,\s*$/', '', $sql);
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
|
||||
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
|
||||
}
|
||||
// Add table from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
if ($object->ismultientitymanaged == 1) {
|
||||
$sql .= " WHERE t.entity IN (".getEntity($object->element).")";
|
||||
} else {
|
||||
$sql .= " WHERE 1 = 1";
|
||||
}
|
||||
foreach ($search as $key => $val) {
|
||||
if ($key == 'status' && $search[$key] == -1) {
|
||||
continue;
|
||||
}
|
||||
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
|
||||
if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
|
||||
if ($search[$key] == '-1') {
|
||||
$search[$key] = '';
|
||||
if (array_key_exists($key, $object->fields)) {
|
||||
if ($key == 'status' && $search[$key] == -1) {
|
||||
continue;
|
||||
}
|
||||
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
|
||||
if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
|
||||
if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
|
||||
$search[$key] = '';
|
||||
}
|
||||
$mode_search = 2;
|
||||
}
|
||||
if ($search[$key] != '') {
|
||||
$sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
|
||||
}
|
||||
} else {
|
||||
if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
|
||||
$columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
|
||||
if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
|
||||
if (preg_match('/_dtstart$/', $key)) {
|
||||
$sql .= " AND t.".$columnName." >= '".$db->idate($search[$key])."'";
|
||||
}
|
||||
if (preg_match('/_dtend$/', $key)) {
|
||||
$sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
$mode_search = 2;
|
||||
}
|
||||
if ($search[$key] != '') {
|
||||
$sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
|
||||
}
|
||||
}
|
||||
if ($search_all) {
|
||||
@ -246,51 +270,69 @@ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $objec
|
||||
$sql .= $hookmanager->resPrint;
|
||||
|
||||
/* If a group by is required
|
||||
$sql.= " GROUP BY "
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
$sql .= " GROUP BY ";
|
||||
foreach($object->fields as $key => $val) {
|
||||
$sql .= "t.".$key.", ";
|
||||
}
|
||||
// Add fields from extrafields
|
||||
if (! empty($extrafields->attributes[$object->table_element]['label'])) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
|
||||
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
|
||||
}
|
||||
}
|
||||
// Add where from hooks
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
|
||||
$sql.=$hookmanager->resPrint;
|
||||
$sql=preg_replace('/,\s*$/','', $sql);
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
$sql = preg_replace('/,\s*$/', '', $sql);
|
||||
*/
|
||||
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
// Add HAVING from hooks
|
||||
/*
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
$sql .= !empty($hookmanager->resPrint) ? (" HAVING 1=1 " . $hookmanager->resPrint) : "";
|
||||
*/
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
/* This old and fast method to get and count full list returns all record so use a high amount of memory.
|
||||
$resql = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($resql);
|
||||
*/
|
||||
/* The slow method does not consume memory on mysql (not tested on pgsql) */
|
||||
/*$resql = $db->query($sql, 0, 'auto', 1);
|
||||
while ($db->fetch_object($resql)) {
|
||||
$nbtotalofrecords++;
|
||||
}*/
|
||||
/* The fast and low memory method to get and count full list converts the sql into a sql count */
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||
$resql = $db->query($sqlforcount);
|
||||
$objforcount = $db->fetch_object($resql);
|
||||
$nbtotalofrecords = $objforcount->nbtotalofrecords;
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
|
||||
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
|
||||
$num = $nbtotalofrecords;
|
||||
} else {
|
||||
if ($limit) {
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
// Complete request and execute it with limit
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
|
||||
// Direct jump if only one record found
|
||||
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
@ -303,7 +345,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $
|
||||
// Output page
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
llxHeader('', $title, $help_url);
|
||||
llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
|
||||
|
||||
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||
|
||||
@ -317,9 +359,11 @@ if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
foreach ($search as $key => $val) {
|
||||
if (is_array($search[$key]) && count($search[$key])) {
|
||||
foreach ($search[$key] as $skey) {
|
||||
$param .= '&search_'.$key.'[]='.urlencode($skey);
|
||||
if ($skey != '') {
|
||||
$param .= '&search_'.$key.'[]='.urlencode($skey);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} elseif ($search[$key] != '') {
|
||||
$param .= '&search_'.$key.'='.urlencode($search[$key]);
|
||||
}
|
||||
}
|
||||
@ -328,11 +372,17 @@ if ($optioncss != '') {
|
||||
}
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
// Add $param from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
$param .= $hookmanager->resPrint;
|
||||
|
||||
// List of mass actions available
|
||||
$arrayofmassactions = array(
|
||||
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
|
||||
//'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
|
||||
//'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
|
||||
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
|
||||
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
|
||||
);
|
||||
if ($permissiontodelete) {
|
||||
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
|
||||
@ -351,24 +401,25 @@ print '<input type="hidden" name="formfilteraction" id="formfilteraction" value=
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
|
||||
$newcardbutton = dolGetButtonTitle($langs->trans('NewAsset'), '', 'fa fa-plus-circle', dol_buildpath('/asset/card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
|
||||
$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/asset/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
|
||||
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
|
||||
|
||||
// Add code for pre mass action (confirmation or email presend form)
|
||||
$topicmail = "SendAssetsRef";
|
||||
$topicmail = "SendAssetRef";
|
||||
$modelmail = "asset";
|
||||
$objecttmp = new Asset($db);
|
||||
$trackid = 'asset'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||
|
||||
if ($sall) {
|
||||
if ($search_all) {
|
||||
foreach ($fieldstosearchall as $key => $val) {
|
||||
$fieldstosearchall[$key] = $langs->trans($val);
|
||||
}
|
||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
|
||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
|
||||
}
|
||||
|
||||
$moreforfilter = '';
|
||||
@ -395,31 +446,42 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfi
|
||||
$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
|
||||
|
||||
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
|
||||
|
||||
// Fields title search
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
||||
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
|
||||
if ($key == 'status') {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
} elseif (in_array($val['type'], array('timestamp'))) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
||||
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
|
||||
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'right';
|
||||
}
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
|
||||
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
|
||||
print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
|
||||
} elseif (strpos($val['type'], 'integer:') === 0) {
|
||||
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
|
||||
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
|
||||
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
|
||||
print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
|
||||
} elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
|
||||
print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
|
||||
} elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
||||
print '<div class="nowrap">';
|
||||
print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
|
||||
print '</div>';
|
||||
} elseif ($key == 'lang') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
$formadmin = new FormAdmin($db);
|
||||
print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
|
||||
} else {
|
||||
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
@ -443,14 +505,14 @@ print '</tr>'."\n";
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
||||
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
|
||||
if ($key == 'status') {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
} elseif (in_array($val['type'], array('timestamp'))) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
||||
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
|
||||
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'right';
|
||||
}
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||
@ -464,13 +526,13 @@ $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$
|
||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Action column
|
||||
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n";
|
||||
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
|
||||
print '</tr>'."\n";
|
||||
|
||||
|
||||
// Detect if we need a fetch on each output line
|
||||
$needToFetchEachLine = 0;
|
||||
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
|
||||
if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
|
||||
if (preg_match('/\$object/', $val)) {
|
||||
$needToFetchEachLine++; // There is at least one compute field that use $object
|
||||
@ -483,6 +545,7 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
|
||||
// --------------------------------------------------------------------
|
||||
$i = 0;
|
||||
$totalarray = array();
|
||||
$totalarray['nbfield'] = 0;
|
||||
while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if (empty($obj)) {
|
||||
@ -495,7 +558,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
// Show here line of result
|
||||
print '<tr class="oddeven">';
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
||||
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
|
||||
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
} elseif ($key == 'status') {
|
||||
@ -508,14 +571,17 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
||||
}
|
||||
|
||||
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') {
|
||||
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'right';
|
||||
}
|
||||
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
|
||||
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
|
||||
if ($key == 'status') {
|
||||
print $object->getLibStatut(5);
|
||||
} elseif ($key == 'rowid') {
|
||||
print $object->showOutputField($val, $key, $object->id, '');
|
||||
} else {
|
||||
print $object->showOutputField($val, $key, $object->$key, '');
|
||||
}
|
||||
@ -545,7 +611,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
print $hookmanager->resPrint;
|
||||
// Action column
|
||||
print '<td class="nowrap center">';
|
||||
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
$selected = 0;
|
||||
if (in_array($object->id, $arrayofselected)) {
|
||||
$selected = 1;
|
||||
@ -605,7 +671,7 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n
|
||||
$genallowed = $permissiontoread;
|
||||
$delallowed = $permissiontoadd;
|
||||
|
||||
print $formfile->showdocuments('massfilesarea_asset', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '');
|
||||
print $formfile->showdocuments('massfilesarea_asset', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
|
||||
}
|
||||
|
||||
// End of page
|
||||
|
||||
191
htdocs/asset/model/accountancy_codes.php
Normal file
191
htdocs/asset/model/accountancy_codes.php
Normal file
@ -0,0 +1,191 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/model/accountancy_code.php
|
||||
* \ingroup asset
|
||||
* \brief Card with accountancy code on Asset Model
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetmodel.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetaccountancycodes.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("assets", "companies"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new AssetModel($db);
|
||||
$assetaccountancycodes = new AssetAccountancyCodes($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->asset->dir_output . '/temp/massgeneration/' . $user->id;
|
||||
$hookmanager->initHooks(array('assetmodelaccountancycodes', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
|
||||
}
|
||||
|
||||
$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read)));
|
||||
$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php
|
||||
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
$result = $assetaccountancycodes->fetchAccountancyCodes(0, $object->id);
|
||||
if ($result < 0) {
|
||||
setEventMessages($assetaccountancycodes->error, $assetaccountancycodes->errors, 'errors');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
if (empty($reshook)) {
|
||||
$backurlforlist = DOL_URL_ROOT.'/asset/list.php';
|
||||
|
||||
if (empty($backtopage) || ($cancel && empty($id))) {
|
||||
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
|
||||
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
|
||||
$backtopage = $backurlforlist;
|
||||
} else {
|
||||
$backtopage = DOL_URL_ROOT.'/asset/model/accountancy_codes.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($cancel) {
|
||||
/*var_dump($cancel);var_dump($backtopage);var_dump($backtopageforcancel);exit;*/
|
||||
if (!empty($backtopageforcancel)) {
|
||||
header("Location: ".$backtopageforcancel);
|
||||
exit;
|
||||
} elseif (!empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
$action = '';
|
||||
}
|
||||
|
||||
if ($action == "update") {
|
||||
$assetaccountancycodes->setAccountancyCodesFromPost();
|
||||
|
||||
$result = $assetaccountancycodes->updateAccountancyCodes($user, 0, $object->id);
|
||||
if ($result < 0) {
|
||||
setEventMessages($assetaccountancycodes->error, $assetaccountancycodes->errors, 'errors');
|
||||
$action = 'edit';
|
||||
} else {
|
||||
setEventMessage($langs->trans('RecordSaved'));
|
||||
header("Location: " . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$help_url = '';
|
||||
llxHeader('', $langs->trans('AssetModel'), $help_url);
|
||||
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$head = assetModelPrepareHead($object);
|
||||
print dol_get_fiche_head($head, 'accountancy_codes', $langs->trans("AssetModel"), -1, $object->picto);
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/asset/model/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '</div>';
|
||||
|
||||
if ($action == 'edit') {
|
||||
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '">';
|
||||
print '<input type="hidden" name="token" value="' . newToken() . '">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
if ($backtopage) {
|
||||
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
|
||||
}
|
||||
if ($backtopageforcancel) {
|
||||
print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
|
||||
}
|
||||
|
||||
print dol_get_fiche_head(array(), '');
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/asset/tpl/accountancy_codes_edit.tpl.php';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print $form->buttonsSaveCancel();
|
||||
|
||||
print '</form>';
|
||||
} else {
|
||||
include DOL_DOCUMENT_ROOT . '/asset/tpl/accountancy_codes_view.tpl.php';
|
||||
}
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
if ($action != 'edit') {
|
||||
print '<div class="tabsAction">' . "\n";
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
if ($object->status == $object::STATUS_DRAFT/* && !empty($object->enabled_modes)*/) {
|
||||
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit&token=' . newToken(), '', $permissiontoadd);
|
||||
}
|
||||
}
|
||||
print '</div>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
217
htdocs/asset/model/agenda.php
Normal file
217
htdocs/asset/model/agenda.php
Normal file
@ -0,0 +1,217 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/model/agenda.php
|
||||
* \ingroup asset
|
||||
* \brief Tab of events on Asset Model
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetmodel.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("assets", "other"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
if (GETPOST('actioncode', 'array')) {
|
||||
$actioncode = GETPOST('actioncode', 'array', 3);
|
||||
if (!count($actioncode)) {
|
||||
$actioncode = '0';
|
||||
}
|
||||
} else {
|
||||
$actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
|
||||
}
|
||||
$search_agenda_label = GETPOST('search_agenda_label');
|
||||
|
||||
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortfield) {
|
||||
$sortfield = 'a.datep,a.id';
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = 'DESC,DESC';
|
||||
}
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new AssetModel($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->asset->dir_output . '/temp/massgeneration/' . $user->id;
|
||||
$hookmanager->initHooks(array('assetmodelagenda', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$upload_dir = $conf->asset->multidir_output[$object->entity] . "/model/" . $object->id;
|
||||
}
|
||||
|
||||
$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read)));
|
||||
$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php
|
||||
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
if ($user->socid > 0) $socid = $user->socid;
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters = array('id' => $id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
// Cancel
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
|
||||
header("Location: " . $backtopage);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$actioncode = '';
|
||||
$search_agenda_label = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
if ($object->id > 0) {
|
||||
$title = $langs->trans("Agenda");
|
||||
//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
|
||||
$help_url = 'EN:Module_Agenda_En';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if (!empty($conf->notification->enabled)) {
|
||||
$langs->load("mails");
|
||||
}
|
||||
$head = assetModelPrepareHead($object);
|
||||
|
||||
|
||||
print dol_get_fiche_head($head, 'agenda', $langs->trans("AssetModel"), -1, $object->picto);
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/asset/model/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
$object->info($object->id);
|
||||
dol_print_object_info($object, 1);
|
||||
|
||||
print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
|
||||
// Actions buttons
|
||||
|
||||
$objthirdparty = $object;
|
||||
$objcon = new stdClass();
|
||||
|
||||
$out = '&origin=' . urlencode($object->element . '@' . $object->module) . '&originid=' . urlencode($object->id);
|
||||
$urlbacktopage = $_SERVER['PHP_SELF'] . '?id=' . $object->id;
|
||||
$out .= '&backtopage=' . urlencode($urlbacktopage);
|
||||
$permok = $user->rights->agenda->myactions->create;
|
||||
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
|
||||
//$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
|
||||
if (get_class($objthirdparty) == 'Societe') {
|
||||
$out .= '&socid=' . urlencode($objthirdparty->id);
|
||||
}
|
||||
$out .= (!empty($objcon->id) ? '&contactid=' . urlencode($objcon->id) : '') . '&percentage=-1';
|
||||
//$out.=$langs->trans("AddAnAction").' ';
|
||||
//$out.=img_picto($langs->trans("AddAnAction"),'filenew');
|
||||
//$out.="</a>";
|
||||
}
|
||||
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
// if (!empty($conf->agenda->enabled)) {
|
||||
// if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
|
||||
// print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create' . $out . '">' . $langs->trans("AddAction") . '</a>';
|
||||
// } else {
|
||||
// print '<a class="butActionRefused classfortooltip" href="#">' . $langs->trans("AddAction") . '</a>';
|
||||
// }
|
||||
// }
|
||||
|
||||
print '</div>';
|
||||
|
||||
// if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
|
||||
// $param = '&id=' . $object->id . '&socid=' . $socid;
|
||||
// if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
// $param .= '&contextpage=' . urlencode($contextpage);
|
||||
// }
|
||||
// if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
// $param .= '&limit=' . urlencode($limit);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// print load_fiche_titre($langs->trans("ActionsOnAssetModel"), '', '');
|
||||
//
|
||||
// // List of all actions
|
||||
// $filters = array();
|
||||
// $filters['search_agenda_label'] = $search_agenda_label;
|
||||
//
|
||||
// // TODO Replace this with same code than into list.php
|
||||
// show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
|
||||
// }
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
330
htdocs/asset/model/card.php
Normal file
330
htdocs/asset/model/card.php
Normal file
@ -0,0 +1,330 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/model/card.php
|
||||
* \ingroup asset
|
||||
* \brief Page to create/edit/view asset Model
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetmodel.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("assets", "other"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'assetmodelcard'; // To manage different context of search
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new AssetModel($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->asset->dir_output . '/temp/massgeneration/' . $user->id;
|
||||
$hookmanager->initHooks(array('assetmodelcard', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
||||
|
||||
// Initialize array of search criterias
|
||||
$search_all = GETPOST("search_all", 'alpha');
|
||||
$search = array();
|
||||
foreach ($object->fields as $key => $val) {
|
||||
if (GETPOST('search_' . $key, 'alpha')) {
|
||||
$search[$key] = GETPOST('search_' . $key, 'alpha');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($action) && empty($id) && empty($ref)) {
|
||||
$action = 'view';
|
||||
}
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
|
||||
|
||||
$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read)));
|
||||
$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||
$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->delete))) || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
||||
$permissionnote = $permissiontoadd; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiondellink = $permissiontoadd; // Used by the include of actions_dellink.inc.php
|
||||
$upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1];
|
||||
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
if ($user->socid > 0) $socid = $user->socid;
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
$error = 0;
|
||||
|
||||
$backurlforlist = DOL_URL_ROOT . '/asset/model/list.php';
|
||||
|
||||
if (empty($backtopage) || ($cancel && empty($id))) {
|
||||
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
|
||||
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
|
||||
$backtopage = $backurlforlist;
|
||||
} else {
|
||||
$backtopage = DOL_URL_ROOT . '/asset/model/card.php?id=' . ((!empty($id) && $id > 0) ? $id : '__ID__');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$triggermodname = 'ASSETMODEL_MODIFY'; // Name of trigger action code to execute when we modify record
|
||||
|
||||
if (($action == 'edit' && !($permissiontoadd && $object->status == $object::STATUS_DRAFT)) ||
|
||||
($action == 'confirm_setdraft' && !($permissiontoadd && $object->status != $object::STATUS_DRAFT)) ||
|
||||
($action == 'confirm_validate' && !($permissiontoadd && $object->status != $object::STATUS_VALIDATED)) ||
|
||||
($action == 'confirm_close' && !($permissiontoadd && $object->status != $object::STATUS_CANCELED))
|
||||
) {
|
||||
$action = "";
|
||||
}
|
||||
|
||||
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_addupdatedelete.inc.php';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*
|
||||
* Put here all code to build page
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
|
||||
$title = $langs->trans("AssetModel") . ' - ' . $langs->trans("Card");
|
||||
$help_url = '';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
// Part to create
|
||||
if ($action == 'create') {
|
||||
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("AssetModel")), '', 'object_' . $object->picto);
|
||||
|
||||
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||
print '<input type="hidden" name="token" value="' . newToken() . '">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
if ($backtopage) {
|
||||
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
|
||||
}
|
||||
if ($backtopageforcancel) {
|
||||
print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
|
||||
}
|
||||
|
||||
print dol_get_fiche_head(array(), '');
|
||||
|
||||
// Set some default values
|
||||
//if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
|
||||
|
||||
print '<table class="border centpercent tableforfieldcreate">' . "\n";
|
||||
|
||||
// Common attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';
|
||||
|
||||
// Other attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';
|
||||
|
||||
print '</table>' . "\n";
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print $form->buttonsSaveCancel("Create");
|
||||
|
||||
print '</form>';
|
||||
|
||||
//dol_set_focus('input[name="ref"]');
|
||||
}
|
||||
|
||||
// Part to edit record
|
||||
if (($id || $ref) && $action == 'edit') {
|
||||
print load_fiche_titre($langs->trans("AssetModel"), '', 'object_' . $object->picto);
|
||||
|
||||
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||
print '<input type="hidden" name="token" value="' . newToken() . '">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="' . $object->id . '">';
|
||||
if ($backtopage) {
|
||||
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
|
||||
}
|
||||
if ($backtopageforcancel) {
|
||||
print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
|
||||
}
|
||||
|
||||
print dol_get_fiche_head();
|
||||
|
||||
print '<table class="border centpercent tableforfieldedit">' . "\n";
|
||||
|
||||
// Common attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';
|
||||
|
||||
// Other attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print $form->buttonsSaveCancel();
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
// Part to show record
|
||||
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
|
||||
$res = $object->fetch_optionals();
|
||||
|
||||
$head = assetModelPrepareHead($object);
|
||||
print dol_get_fiche_head($head, 'card', $langs->trans("AssetModel"), -1, $object->picto);
|
||||
|
||||
$formconfirm = '';
|
||||
|
||||
// Confirmation to delete
|
||||
if ($action == 'delete') {
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteAssetModel'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
|
||||
} elseif ($action == 'clone') {
|
||||
// Clone confirmation
|
||||
// Create an array for form
|
||||
$formquestion = array();
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
|
||||
}
|
||||
|
||||
// Call Hook formConfirm
|
||||
$parameters = array('formConfirm' => $formconfirm);
|
||||
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) {
|
||||
$formconfirm .= $hookmanager->resPrint;
|
||||
} elseif ($reshook > 0) {
|
||||
$formconfirm = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
// Print form confirm
|
||||
print $formconfirm;
|
||||
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/asset/model/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">' . "\n";
|
||||
|
||||
// Common attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
|
||||
|
||||
// Other attributes. Fields from hook formObjectOptions and Extrafields.
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '<div class="clearboth"></div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
|
||||
// Buttons for actions
|
||||
if ($action != 'editline') {
|
||||
print '<div class="tabsAction">' . "\n";
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
if ($object->status == $object::STATUS_DRAFT) {
|
||||
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit&token=' . newToken(), '', $permissiontoadd);
|
||||
}
|
||||
|
||||
// Back to draft
|
||||
if ($object->status != $object::STATUS_DRAFT) {
|
||||
print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=confirm_setdraft&confirm=yes&token=' . newToken(), '', $permissiontoadd);
|
||||
}
|
||||
|
||||
if ($object->status != $object::STATUS_VALIDATED) {
|
||||
print dolGetButtonAction($langs->trans('Enable'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=confirm_validate&confirm=yes&token=' . newToken(), '', $permissiontoadd);
|
||||
}
|
||||
|
||||
if ($object->status != $object::STATUS_CANCELED) {
|
||||
print dolGetButtonAction($langs->trans('Disable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_close&confirm=yes&token='.newToken(), '', $permissiontoadd);
|
||||
}
|
||||
|
||||
// Clone
|
||||
print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&socid=' . $object->socid . '&action=clone&token=' . newToken(), '', $permissiontoadd);
|
||||
|
||||
// Delete (need delete permission, or if draft, just need create/modify permission)
|
||||
print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
|
||||
}
|
||||
print '</div>' . "\n";
|
||||
}
|
||||
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
print '<a name="builddoc"></a>'; // ancre
|
||||
|
||||
print '</div><div class="fichehalfright">';
|
||||
|
||||
// $MAXEVENT = 10;
|
||||
//
|
||||
// $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT . '/asset/model/agenda.php?id=' . $object->id);
|
||||
//
|
||||
// // List of actions on element
|
||||
// include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||
// $formactions = new FormActions($db);
|
||||
// $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, 0, 1, '', $MAXEVENT, '', $morehtmlright);
|
||||
|
||||
print '</div></div>';
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
191
htdocs/asset/model/depreciation_options.php
Normal file
191
htdocs/asset/model/depreciation_options.php
Normal file
@ -0,0 +1,191 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/model/depreciation_options.php
|
||||
* \ingroup asset
|
||||
* \brief Card with depreciation options on Asset Model
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetmodel.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetdepreciationoptions.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("assets", "companies"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new AssetModel($db);
|
||||
$assetdepreciationoptions = new AssetDepreciationOptions($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->asset->dir_output . '/temp/massgeneration/' . $user->id;
|
||||
$hookmanager->initHooks(array('assetmodeldeprectationoptions', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
|
||||
}
|
||||
|
||||
$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read)));
|
||||
$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php
|
||||
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
$object->asset_depreciation_options = &$assetdepreciationoptions;
|
||||
$result = $assetdepreciationoptions->fetchDeprecationOptions(0, $object->id);
|
||||
if ($result < 0) {
|
||||
setEventMessages($assetdepreciationoptions->error, $assetdepreciationoptions->errors, 'errors');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
if (empty($reshook)) {
|
||||
$backurlforlist = DOL_URL_ROOT.'/asset/list.php';
|
||||
|
||||
if (empty($backtopage) || ($cancel && empty($id))) {
|
||||
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
|
||||
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
|
||||
$backtopage = $backurlforlist;
|
||||
} else {
|
||||
$backtopage = DOL_URL_ROOT.'/asset/model/depreciation_options.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($cancel) {
|
||||
/*var_dump($cancel);var_dump($backtopage);var_dump($backtopageforcancel);exit;*/
|
||||
if (!empty($backtopageforcancel)) {
|
||||
header("Location: ".$backtopageforcancel);
|
||||
exit;
|
||||
} elseif (!empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
$action = '';
|
||||
}
|
||||
|
||||
if ($action == "update") {
|
||||
$result = $assetdepreciationoptions->setDeprecationOptionsFromPost(1);
|
||||
if ($result > 0) $result = $assetdepreciationoptions->updateDeprecationOptions($user, 0, $object->id);
|
||||
if ($result < 0) {
|
||||
setEventMessages($assetdepreciationoptions->error, $assetdepreciationoptions->errors, 'errors');
|
||||
$action = 'edit';
|
||||
} else {
|
||||
setEventMessage($langs->trans('RecordSaved'));
|
||||
header("Location: " . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$help_url = '';
|
||||
llxHeader('', $langs->trans('AssetModel'), $help_url);
|
||||
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$head = assetModelPrepareHead($object);
|
||||
print dol_get_fiche_head($head, 'depreciation_options', $langs->trans("AssetModel"), -1, $object->picto);
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/asset/model/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '</div>';
|
||||
|
||||
if ($action == 'edit') {
|
||||
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '">';
|
||||
print '<input type="hidden" name="token" value="' . newToken() . '">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
if ($backtopage) {
|
||||
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
|
||||
}
|
||||
if ($backtopageforcancel) {
|
||||
print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
|
||||
}
|
||||
|
||||
print dol_get_fiche_head(array(), '');
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/asset/tpl/depreciation_options_edit.tpl.php';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print $form->buttonsSaveCancel();
|
||||
|
||||
print '</form>';
|
||||
} else {
|
||||
include DOL_DOCUMENT_ROOT . '/asset/tpl/depreciation_options_view.tpl.php';
|
||||
}
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
if ($action != 'edit') {
|
||||
print '<div class="tabsAction">' . "\n";
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
if ($object->status == $object::STATUS_DRAFT/* && !empty($object->enabled_modes)*/) {
|
||||
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit&token=' . newToken(), '', $permissiontoadd);
|
||||
}
|
||||
}
|
||||
print '</div>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
681
htdocs/asset/model/list.php
Normal file
681
htdocs/asset/model/list.php
Normal file
@ -0,0 +1,681 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/model/list.php
|
||||
* \ingroup asset
|
||||
* \brief List page for asset model
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/asset/class/assetmodel.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("assets", "other"));
|
||||
|
||||
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
|
||||
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
|
||||
$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
|
||||
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
|
||||
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
|
||||
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'assetmodellist'; // To manage different context of search
|
||||
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
||||
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
||||
|
||||
$id = GETPOST('id', 'int');
|
||||
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new AssetModel($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('assetmodellist')); // Note that conf->hooks_modules contains array
|
||||
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
//$extrafields->fetch_name_optionals_label($object->table_element_line);
|
||||
|
||||
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
||||
|
||||
// Default sort order (if not yet defined by previous GETPOST)
|
||||
if (!$sortfield) {
|
||||
reset($object->fields); // Reset is required to avoid key() to return null.
|
||||
$sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
|
||||
// Initialize array of search criterias
|
||||
$search_all = GETPOST('search_all', 'alphanohtml');
|
||||
$search = array();
|
||||
foreach ($object->fields as $key => $val) {
|
||||
if ($key == 'fk_pays' && !GETPOSTISSET('search_'.$key)) {
|
||||
$search[$key] = $mysoc->country_id;
|
||||
} elseif (GETPOST('search_'.$key, 'alpha') !== '') {
|
||||
$search[$key] = GETPOST('search_'.$key, 'alpha');
|
||||
}
|
||||
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
||||
$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
|
||||
$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
|
||||
}
|
||||
}
|
||||
|
||||
// List of fields to search into when doing a "search in all"
|
||||
$fieldstosearchall = array();
|
||||
foreach ($object->fields as $key => $val) {
|
||||
if (!empty($val['searchall'])) {
|
||||
$fieldstosearchall['t.'.$key] = $val['label'];
|
||||
}
|
||||
}
|
||||
|
||||
// Definition of array of fields for columns
|
||||
$arrayfields = array();
|
||||
foreach ($object->fields as $key => $val) {
|
||||
// If $val['visible']==0, then we never show the field
|
||||
if (!empty($val['visible'])) {
|
||||
$visible = (int) dol_eval($val['visible'], 1);
|
||||
$arrayfields['t.'.$key] = array(
|
||||
'label'=>$val['label'],
|
||||
'checked'=>(($visible < 0) ? 0 : 1),
|
||||
'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
|
||||
'position'=>$val['position'],
|
||||
'help'=> isset($val['help']) ? $val['help'] : ''
|
||||
);
|
||||
}
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read)));
|
||||
$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write)));
|
||||
$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->delete)));
|
||||
|
||||
// Security check
|
||||
if (empty($conf->asset->enabled)) {
|
||||
accessforbidden('Module not enabled');
|
||||
}
|
||||
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
$socid = 0; if ($user->socid > 0) $socid = $user->socid;
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$action = 'list';
|
||||
$massaction = '';
|
||||
}
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||
$massaction = '';
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
// Selection of new fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$search[$key] = '';
|
||||
if ($key == 'fk_pays') $search[$key] = $mysoc->country_id;
|
||||
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
||||
$search[$key.'_dtstart'] = '';
|
||||
$search[$key.'_dtend'] = '';
|
||||
}
|
||||
}
|
||||
$toselect = array();
|
||||
$search_array_options = array();
|
||||
}
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|
||||
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
|
||||
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
|
||||
}
|
||||
|
||||
// Mass actions
|
||||
$objectclass = 'AssetModel';
|
||||
$objectlabel = 'AssetModel';
|
||||
$uploaddir = $conf->asset->dir_output;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
$help_url = '';
|
||||
$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("AssetModels"));
|
||||
$morejs = array();
|
||||
$morecss = array();
|
||||
|
||||
|
||||
// Build and execute select
|
||||
// --------------------------------------------------------------------
|
||||
$sql = 'SELECT ';
|
||||
$sql .= $object->getFieldList('t');
|
||||
// Add fields from extrafields
|
||||
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
|
||||
}
|
||||
}
|
||||
// Add fields from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
|
||||
$sql = preg_replace('/,\s*$/', '', $sql);
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
|
||||
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
|
||||
}
|
||||
// Add table from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
if ($object->ismultientitymanaged == 1) {
|
||||
$sql .= " WHERE t.entity IN (".getEntity($object->element).")";
|
||||
} else {
|
||||
$sql .= " WHERE 1 = 1";
|
||||
}
|
||||
foreach ($search as $key => $val) {
|
||||
if (array_key_exists($key, $object->fields)) {
|
||||
if ($key == 'status' && $search[$key] == -1) {
|
||||
continue;
|
||||
}
|
||||
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
|
||||
if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
|
||||
if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
|
||||
$search[$key] = '';
|
||||
}
|
||||
$mode_search = 2;
|
||||
}
|
||||
if ($search[$key] != '') {
|
||||
$sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
|
||||
}
|
||||
} else {
|
||||
if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
|
||||
$columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
|
||||
if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
|
||||
if (preg_match('/_dtstart$/', $key)) {
|
||||
$sql .= " AND t.".$columnName." >= '".$db->idate($search[$key])."'";
|
||||
}
|
||||
if (preg_match('/_dtend$/', $key)) {
|
||||
$sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($search_all) {
|
||||
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
|
||||
}
|
||||
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
|
||||
// Add where from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||
// Add where from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
|
||||
/* If a group by is required
|
||||
$sql .= " GROUP BY ";
|
||||
foreach($object->fields as $key => $val) {
|
||||
$sql .= "t.".$key.", ";
|
||||
}
|
||||
// Add fields from extrafields
|
||||
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
|
||||
}
|
||||
}
|
||||
// Add where from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
$sql = preg_replace('/,\s*$/', '', $sql);
|
||||
*/
|
||||
|
||||
// Add HAVING from hooks
|
||||
/*
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
$sql .= !empty($hookmanager->resPrint) ? (" HAVING 1=1 " . $hookmanager->resPrint) : "";
|
||||
*/
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
/* This old and fast method to get and count full list returns all record so use a high amount of memory.
|
||||
$resql = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($resql);
|
||||
*/
|
||||
/* The slow method does not consume memory on mysql (not tested on pgsql) */
|
||||
/*$resql = $db->query($sql, 0, 'auto', 1);
|
||||
while ($db->fetch_object($resql)) {
|
||||
$nbtotalofrecords++;
|
||||
}*/
|
||||
/* The fast and low memory method to get and count full list converts the sql into a sql count */
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||
$resql = $db->query($sqlforcount);
|
||||
$objforcount = $db->fetch_object($resql);
|
||||
$nbtotalofrecords = $objforcount->nbtotalofrecords;
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
|
||||
// Complete request and execute it with limit
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
|
||||
// Direct jump if only one record found
|
||||
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$id = $obj->rowid;
|
||||
header("Location: ".DOL_URL_ROOT.'/asset/model/card.php?id='.$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// Output page
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
|
||||
|
||||
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
foreach ($search as $key => $val) {
|
||||
if (is_array($search[$key]) && count($search[$key])) {
|
||||
foreach ($search[$key] as $skey) {
|
||||
if ($skey != '') {
|
||||
$param .= '&search_'.$key.'[]='.urlencode($skey);
|
||||
}
|
||||
}
|
||||
} elseif ($search[$key] != '') {
|
||||
$param .= '&search_'.$key.'='.urlencode($search[$key]);
|
||||
}
|
||||
}
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
// Add $param from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
$param .= $hookmanager->resPrint;
|
||||
|
||||
// List of mass actions available
|
||||
$arrayofmassactions = array(
|
||||
//'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
|
||||
//'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
|
||||
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
|
||||
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
|
||||
);
|
||||
if ($permissiontodelete) {
|
||||
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
|
||||
}
|
||||
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
|
||||
$arrayofmassactions = array();
|
||||
}
|
||||
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
|
||||
$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/asset/model/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
|
||||
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
|
||||
|
||||
// Add code for pre mass action (confirmation or email presend form)
|
||||
$topicmail = "SendAssetModelRef";
|
||||
$modelmail = "assetmodel";
|
||||
$objecttmp = new AssetModel($db);
|
||||
$trackid = 'assetmodel'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||
|
||||
if ($search_all) {
|
||||
foreach ($fieldstosearchall as $key => $val) {
|
||||
$fieldstosearchall[$key] = $langs->trans($val);
|
||||
}
|
||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
|
||||
}
|
||||
|
||||
$moreforfilter = '';
|
||||
/*$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
|
||||
$moreforfilter.= '</div>';*/
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) {
|
||||
$moreforfilter .= $hookmanager->resPrint;
|
||||
} else {
|
||||
$moreforfilter = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
if (!empty($moreforfilter)) {
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
|
||||
|
||||
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
|
||||
print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
|
||||
|
||||
// Fields title search
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
|
||||
if ($key == 'status') {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
} elseif (in_array($val['type'], array('timestamp'))) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
||||
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'right';
|
||||
}
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
|
||||
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
|
||||
print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
|
||||
} elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
|
||||
print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
|
||||
} elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
||||
print '<div class="nowrap">';
|
||||
print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
|
||||
print '</div>';
|
||||
} elseif ($key == 'lang') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
$formadmin = new FormAdmin($db);
|
||||
print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
|
||||
} else {
|
||||
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
||||
|
||||
// Fields from hook
|
||||
$parameters = array('arrayfields'=>$arrayfields);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Action column
|
||||
print '<td class="liste_titre maxwidthsearch">';
|
||||
$searchpicto = $form->showFilterButtons();
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
|
||||
// Fields title label
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
|
||||
if ($key == 'status') {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
} elseif (in_array($val['type'], array('timestamp'))) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
||||
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'right';
|
||||
}
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
|
||||
}
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
// Hook fields
|
||||
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Action column
|
||||
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
|
||||
print '</tr>'."\n";
|
||||
|
||||
|
||||
// Detect if we need a fetch on each output line
|
||||
$needToFetchEachLine = 0;
|
||||
if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
|
||||
if (preg_match('/\$object/', $val)) {
|
||||
$needToFetchEachLine++; // There is at least one compute field that use $object
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Loop on record
|
||||
// --------------------------------------------------------------------
|
||||
$i = 0;
|
||||
$totalarray = array();
|
||||
$totalarray['nbfield'] = 0;
|
||||
while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if (empty($obj)) {
|
||||
break; // Should not happen
|
||||
}
|
||||
|
||||
// Store properties in $object
|
||||
$object->setVarsFromFetchObj($obj);
|
||||
|
||||
// Show here line of result
|
||||
print '<tr class="oddeven">';
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
|
||||
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
} elseif ($key == 'status') {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
}
|
||||
|
||||
if (in_array($val['type'], array('timestamp'))) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
||||
} elseif ($key == 'ref') {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
||||
}
|
||||
|
||||
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
|
||||
$cssforfield .= ($cssforfield ? ' ' : '').'right';
|
||||
}
|
||||
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
|
||||
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
|
||||
if ($key == 'status') {
|
||||
print $object->getLibStatut(5);
|
||||
} elseif ($key == 'rowid') {
|
||||
print $object->showOutputField($val, $key, $object->id, '');
|
||||
} else {
|
||||
print $object->showOutputField($val, $key, $object->$key, '');
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
|
||||
if (!$i) {
|
||||
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
|
||||
}
|
||||
if (!isset($totalarray['val'])) {
|
||||
$totalarray['val'] = array();
|
||||
}
|
||||
if (!isset($totalarray['val']['t.'.$key])) {
|
||||
$totalarray['val']['t.'.$key] = 0;
|
||||
}
|
||||
$totalarray['val']['t.'.$key] += $object->$key;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
|
||||
// Fields from hook
|
||||
$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Action column
|
||||
print '<td class="nowrap center">';
|
||||
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
$selected = 0;
|
||||
if (in_array($object->id, $arrayofselected)) {
|
||||
$selected = 1;
|
||||
}
|
||||
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
print '</tr>'."\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Show total line
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
|
||||
|
||||
// If no record found
|
||||
if ($num == 0) {
|
||||
$colspan = 1;
|
||||
foreach ($arrayfields as $key => $val) {
|
||||
if (!empty($val['checked'])) {
|
||||
$colspan++;
|
||||
}
|
||||
}
|
||||
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
$db->free($resql);
|
||||
|
||||
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print '</table>'."\n";
|
||||
print '</div>'."\n";
|
||||
|
||||
print '</form>'."\n";
|
||||
|
||||
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
|
||||
$hidegeneratedfilelistifempty = 1;
|
||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
|
||||
$hidegeneratedfilelistifempty = 0;
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
$formfile = new FormFile($db);
|
||||
|
||||
// Show list of available documents
|
||||
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
||||
$urlsource .= str_replace('&', '&', $param);
|
||||
|
||||
$filedir = $diroutputmassaction;
|
||||
$genallowed = $permissiontoread;
|
||||
$delallowed = $permissiontoadd;
|
||||
|
||||
print $formfile->showdocuments('massfilesarea_asset', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
120
htdocs/asset/model/note.php
Normal file
120
htdocs/asset/model/note.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/model/note.php
|
||||
* \ingroup asset
|
||||
* \brief Card with notes on Asset Model
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetmodel.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("assets", "companies"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new AssetModel($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->asset->dir_output . '/temp/massgeneration/' . $user->id;
|
||||
$hookmanager->initHooks(array('assetmodelnote', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
|
||||
}
|
||||
|
||||
$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read)));
|
||||
$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php
|
||||
$permissionnote = $permissiontoadd; // Used by the include of actions_setnotes.inc.php
|
||||
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
if ($user->socid > 0) $socid = $user->socid;
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
if (empty($reshook)) {
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$help_url = '';
|
||||
llxHeader('', $langs->trans('AssetModel'), $help_url);
|
||||
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$head = assetModelPrepareHead($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'note', $langs->trans("AssetModel"), -1, $object->picto);
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/asset/model/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
$cssclass = "titlefield";
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/notes.tpl.php';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("asset", "companies"));
|
||||
$langs->loadLangs(array("assets", "companies"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
@ -40,30 +40,24 @@ $backtopage = GETPOST('backtopage', 'alpha');
|
||||
$object = new Asset($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('assetnote')); // Note that conf->hooks_modules contains array
|
||||
|
||||
$hookmanager->initHooks(array('assetnote', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Security check - Protection if external user
|
||||
//if ($user->socid > 0) accessforbidden();
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
//$result = restrictedArea($user, 'asset', $id);
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$upload_dir = $conf->asset->multidir_output[$object->entity]."/".$object->id;
|
||||
}
|
||||
|
||||
// Security check
|
||||
if (!empty($user->socid)) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'asset', $id);
|
||||
$permissionnote = $user->rights->asset->write; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php
|
||||
|
||||
$permissionnote = 1;
|
||||
//$permissionnote=$user->rights->asset->creer; // Used by the include of actions_setnotes.inc.php
|
||||
// Security check (enable the most restrictive one)
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->asset->enabled)) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
@ -78,67 +72,28 @@ if (empty($reshook)) {
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes';
|
||||
$help_url = '';
|
||||
llxHeader('', $langs->trans('Assets'), $help_url);
|
||||
llxHeader('', $langs->trans('Asset'), $help_url);
|
||||
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$head = asset_prepare_head($object);
|
||||
$head = assetPrepareHead($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'note', $langs->trans("Asset"), -1, 'generic');
|
||||
print dol_get_fiche_head($head, 'note', $langs->trans("Asset"), -1, $object->picto);
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/asset/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/asset/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
/*
|
||||
// Ref customer
|
||||
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
|
||||
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
|
||||
// Thirdparty
|
||||
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$langs->load("projects");
|
||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||
if ($user->rights->asset->creer)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
$morehtmlref.=' : ';
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref.='</form>';
|
||||
} else {
|
||||
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||
}
|
||||
} else {
|
||||
if (! empty($object->fk_project)) {
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($object->fk_project);
|
||||
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
||||
$morehtmlref.=$proj->ref;
|
||||
$morehtmlref.='</a>';
|
||||
} else {
|
||||
$morehtmlref.='';
|
||||
}
|
||||
}
|
||||
}*/
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
|
||||
@ -150,7 +105,7 @@ if ($id > 0 || !empty($ref)) {
|
||||
|
||||
|
||||
$cssclass = "titlefield";
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/notes.tpl.php';
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
81
htdocs/asset/tpl/accountancy_codes_edit.tpl.php
Normal file
81
htdocs/asset/tpl/accountancy_codes_edit.tpl.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Show extrafields. It also show fields from hook formAssetAccountancyCode. Need to have following variables defined:
|
||||
* $object (asset, assetmodel, ...)
|
||||
* $assetaccountancycodes
|
||||
* $action
|
||||
* $conf
|
||||
* $langs
|
||||
*
|
||||
* $parameters
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($object) || !is_object($object)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!is_object($form)) {
|
||||
$form = new Form($db);
|
||||
}
|
||||
|
||||
if (!empty($conf->accounting->enabled) && !is_object($formaccounting)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
|
||||
$formaccounting = new FormAccounting($db);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!-- BEGIN PHP TEMPLATE accountancy_code_edit.tpl.php -->
|
||||
<?php
|
||||
|
||||
if (!is_array($parameters)) {
|
||||
$parameters = array();
|
||||
}
|
||||
$parameters['assetaccountancycodes'] = &$assetaccountancycodes;
|
||||
$reshook = $hookmanager->executeHooks('formAssetAccountancyCodes', $parameters, $object, $action);
|
||||
print $hookmanager->resPrint;
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
foreach ($assetaccountancycodes->accountancy_codes_fields as $mode_key => $mode_info) {
|
||||
//if (empty($object->enabled_modes[$mode_key])) continue;
|
||||
|
||||
print load_fiche_titre($langs->trans($mode_info['label']), '', '');
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
foreach ($mode_info['fields'] as $field_key => $field_info) {
|
||||
$html_name = $mode_key . '_' . $field_key;
|
||||
print '<tr><td class="titlefieldcreate">' . $langs->trans($field_info['label']) . '</td><td colspan="3">';
|
||||
$accountancy_code = GETPOSTISSET($html_name) ? GETPOST($html_name, 'aZ09') : (!empty($assetaccountancycodes->accountancy_codes[$mode_key][$field_key]) ? $assetaccountancycodes->accountancy_codes[$mode_key][$field_key] : '');
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
print $formaccounting->select_account($accountancy_code, $html_name, 1, null, 1, 1, 'minwidth150 maxwidth300', 1);
|
||||
} else {
|
||||
print '<input name="' . $html_name . '" class="maxwidth200" value="' . dol_escape_htmltag($accountancy_code) . '">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!-- END PHP TEMPLATE accountancy_code_edit.tpl.php -->
|
||||
82
htdocs/asset/tpl/accountancy_codes_view.tpl.php
Normal file
82
htdocs/asset/tpl/accountancy_codes_view.tpl.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Show extrafields. It also show fields from hook formAssetAccountancyCode. Need to have following variables defined:
|
||||
* $object (asset, assetmodel, ...)
|
||||
* $assetaccountancycodes
|
||||
* $action
|
||||
* $conf
|
||||
* $langs
|
||||
*
|
||||
* $parameters
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($object) || !is_object($object)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!is_object($form)) {
|
||||
$form = new Form($db);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!-- BEGIN PHP TEMPLATE accountancy_code_view.tpl.php -->
|
||||
<?php
|
||||
|
||||
if (!is_array($parameters)) {
|
||||
$parameters = array();
|
||||
}
|
||||
$parameters['assetaccountancycodes'] = &$assetaccountancycodes;
|
||||
$reshook = $hookmanager->executeHooks('formAssetAccountancyCodes', $parameters, $object, $action);
|
||||
print $hookmanager->resPrint;
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
||||
|
||||
foreach ($assetaccountancycodes->accountancy_codes_fields as $mode_key => $mode_info) {
|
||||
//if (empty($object->enabled_modes[$mode_key])) continue;
|
||||
|
||||
print load_fiche_titre($langs->trans($mode_info['label']), '', '');
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
foreach ($mode_info['fields'] as $field_key => $field_info) {
|
||||
print '<tr><td class="titlefieldcreate">' . $langs->trans($field_info['label']) . '</td><td colspan="3">';
|
||||
if (!empty($assetaccountancycodes->accountancy_codes[$mode_key][$field_key])) {
|
||||
$accountancy_code = $assetaccountancycodes->accountancy_codes[$mode_key][$field_key];
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch('', $accountancy_code, 1);
|
||||
|
||||
print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
|
||||
} else {
|
||||
print $accountancy_code;
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!-- END PHP TEMPLATE accountancy_code_view.tpl.php -->
|
||||
228
htdocs/asset/tpl/depreciation_options_edit.tpl.php
Normal file
228
htdocs/asset/tpl/depreciation_options_edit.tpl.php
Normal file
@ -0,0 +1,228 @@
|
||||
<?php
|
||||
/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Show extrafields. It also show fields from hook formAssetAccountancyCode. Need to have following variables defined:
|
||||
* $object (asset, assetmodel, ...)
|
||||
* $assetaccountancycodes
|
||||
* $action
|
||||
* $conf
|
||||
* $langs
|
||||
*
|
||||
* $parameters
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($object) || !is_object($object)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!is_object($form)) {
|
||||
$form = new Form($db);
|
||||
}
|
||||
|
||||
if (!is_object($formadmin)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php';
|
||||
$formadmin = new FormAdmin($db);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!-- BEGIN PHP TEMPLATE depreciation_options_edit.tpl.php -->
|
||||
<?php
|
||||
|
||||
if (!is_array($parameters)) {
|
||||
$parameters = array();
|
||||
}
|
||||
$enabled_field_info = array();
|
||||
if (empty($parameters['enabled_field_info'])) {
|
||||
$parameters['enabled_field_info'] = &$enabled_field_info;
|
||||
}
|
||||
if (empty($parameters['assetdepreciationoptions'])) {
|
||||
$parameters['assetdepreciationoptions'] = &$assetdepreciationoptions;
|
||||
}
|
||||
$reshook = $hookmanager->executeHooks('formAssetDeprecationOptions', $parameters, $object, $action);
|
||||
print $hookmanager->resPrint;
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
$class_type = get_class($object) == 'Asset' ? 0 : 1;
|
||||
foreach ($assetdepreciationoptions->deprecation_options_fields as $mode_key => $mode_info) {
|
||||
if (!empty($mode_info['enabled_field'])) {
|
||||
$info = explode(':', $mode_info['enabled_field']);
|
||||
$enabled_field_info[] = array(
|
||||
'mode_key' => $info[0],
|
||||
'field_key' => $info[1],
|
||||
'value' => $info[2],
|
||||
'target' => 'block_' . $mode_key,
|
||||
);
|
||||
}
|
||||
|
||||
$assetdepreciationoptions->setInfosForMode($mode_key, $class_type, true);
|
||||
$prefix_html_name = $mode_key . '_';
|
||||
|
||||
print '<div id="block_' . $mode_key . '">';
|
||||
print load_fiche_titre($langs->trans($mode_info['label']), '', '');
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">' . "\n";
|
||||
$mode_info['fields'] = dol_sort_array($mode_info['fields'], 'position');
|
||||
foreach ($mode_info['fields'] as $field_key => $field_info) {
|
||||
// Discard if extrafield is a hidden field on form
|
||||
if (abs($field_info['visible']) != 1 && abs($field_info['visible']) != 3 && abs($field_info['visible']) != 4) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists('enabled', $field_info) && isset($field_info['enabled']) && !verifCond($field_info['enabled'])) {
|
||||
continue; // We don't want this field
|
||||
}
|
||||
if (!empty($field_info['column_break'])) {
|
||||
print '</table>';
|
||||
|
||||
// We close div and reopen for second column
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
}
|
||||
|
||||
$html_name = $prefix_html_name . $field_key;
|
||||
if (!empty($field_info['enabled_field'])) {
|
||||
$info = explode(':', $field_info['enabled_field']);
|
||||
$enabled_field_info[] = array(
|
||||
'mode_key' => $info[0],
|
||||
'field_key' => $info[1],
|
||||
'value' => $info[2],
|
||||
'target' => 'field_' . $html_name,
|
||||
);
|
||||
}
|
||||
|
||||
$more_class = '';
|
||||
if (!empty($field_info['required']) || (isset($field_info['notnull']) && $field_info['notnull'] > 0)) {
|
||||
$more_class .= ' fieldrequired';
|
||||
}
|
||||
if (preg_match('/^(text|html)/', $val['type'])) {
|
||||
$more_class .= ' tdtop';
|
||||
}
|
||||
|
||||
print '<tr class="field_' . $html_name . '" id="field_' . $html_name . '"><td';
|
||||
print ' class="titlefieldcreate' . $more_class . '">';
|
||||
if (!empty($field_info['help'])) {
|
||||
print $form->textwithpicto($langs->trans($field_info['label']), $langs->trans($field_info['help']));
|
||||
} else {
|
||||
print $langs->trans($field_info['label']);
|
||||
}
|
||||
print '</td>';
|
||||
print '<td class="valuefieldcreate">';
|
||||
if (!empty($field_info['picto'])) {
|
||||
print img_picto('', $field_info['picto'], '', false, 0, 0, '', 'pictofixedwidth');
|
||||
}
|
||||
if (in_array($field_info['type'], array('int', 'integer'))) {
|
||||
$value = GETPOSTISSET($html_name) ?GETPOST($html_name, 'int') : $assetdepreciationoptions->$field_key;
|
||||
} elseif ($field_info['type'] == 'double') {
|
||||
$value = GETPOSTISSET($html_name) ? price2num(GETPOST($html_name, 'alphanohtml')) : $assetdepreciationoptions->$field_key;
|
||||
} elseif (preg_match('/^(text|html)/', $field_info['type'])) {
|
||||
$tmparray = explode(':', $field_info['type']);
|
||||
if (!empty($tmparray[1])) {
|
||||
$check = $tmparray[1];
|
||||
} else {
|
||||
$check = 'restricthtml';
|
||||
}
|
||||
$value = GETPOSTISSET($html_name) ? GETPOST($html_name, $check) : $assetdepreciationoptions->$field_key;
|
||||
} elseif ($field_info['type'] == 'price') {
|
||||
$value = GETPOSTISSET($html_name) ? price2num(GETPOST($html_name)) : ($assetdepreciationoptions->$field_key ? price2num($assetdepreciationoptions->$field_key) : (!empty($field_info['default']) ? dol_eval($field_info['default'], 1) : 0));
|
||||
} elseif ($field_key == 'lang') {
|
||||
$value = GETPOSTISSET($html_name) ? GETPOST($html_name, 'aZ09') : $assetdepreciationoptions->lang;
|
||||
} else {
|
||||
$value = GETPOSTISSET($html_name) ? GETPOST($html_name, 'alpha') : $assetdepreciationoptions->$field_key;
|
||||
}
|
||||
if (!empty($field_info['noteditable'])) {
|
||||
print $assetdepreciationoptions->showOutputField($field_info, $field_key, $value, '', '', $prefix_html_name, 0);
|
||||
} else {
|
||||
if ($field_key == 'lang') {
|
||||
print img_picto('', 'language', 'class="pictofixedwidth"');
|
||||
print $formadmin->select_language($value, $html_name, 0, null, 1, 0, 0, 'minwidth300', 2);
|
||||
} else {
|
||||
print $assetdepreciationoptions->showInputField($field_info, $field_key, $value, '', '', $prefix_html_name, 0);
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
print '<div class="clearboth"></div>';
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($enabled_field_info)) {
|
||||
$enabled_field_info = json_encode($enabled_field_info);
|
||||
print <<<SCRIPT
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function () {
|
||||
var enabled_field_info = $enabled_field_info;
|
||||
|
||||
// Init fields
|
||||
enabled_field_info.map(function(info) {
|
||||
var html_name = info.mode_key + '_' + info.field_key;
|
||||
var source = $('#' + html_name);
|
||||
if (!(source.length > 0)) source = $('[name="' + html_name + '"]');
|
||||
if (source.length > 0) {
|
||||
source.attr('data-asset-enabled-field-value', info.value);
|
||||
source.attr('data-asset-enabled-field-target', info.target);
|
||||
updateEnabledField(source);
|
||||
source.on('change click', function() {
|
||||
updateEnabledField(jQuery(this));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function updateEnabledField(_this) {
|
||||
var value = _this.attr('data-asset-enabled-field-value');
|
||||
var target_name = _this.attr('data-asset-enabled-field-target');
|
||||
|
||||
// for block mode
|
||||
var target = $('div#' + target_name);
|
||||
|
||||
// for field
|
||||
if (!(target.length > 0)) {
|
||||
target = $('#' + target_name);
|
||||
if (!(target.length > 0)) target = $('[name="' + target_name + '"]');
|
||||
if (target.length > 0) target = target.closest('tr');
|
||||
}
|
||||
|
||||
if (target.length > 0) {
|
||||
var source_value = _this.attr('type') == 'checkbox' ? (_this.is(':checked') ? 1 : 0) : _this.val();
|
||||
|
||||
if (source_value != value) {
|
||||
target.hide();
|
||||
} else {
|
||||
target.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
SCRIPT;
|
||||
}
|
||||
|
||||
?>
|
||||
<!-- END PHP TEMPLATE depreciation_options_edit.tpl.php -->
|
||||
154
htdocs/asset/tpl/depreciation_options_view.tpl.php
Normal file
154
htdocs/asset/tpl/depreciation_options_view.tpl.php
Normal file
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Show extrafields. It also show fields from hook formAssetAccountancyCode. Need to have following variables defined:
|
||||
* $object (asset, assetmodel, ...)
|
||||
* $assetaccountancycodes
|
||||
* $action
|
||||
* $conf
|
||||
* $langs
|
||||
*
|
||||
* $parameters
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($object) || !is_object($object)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!is_object($form)) {
|
||||
$form = new Form($db);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!-- BEGIN PHP TEMPLATE depreciation_options_view.tpl.php -->
|
||||
<?php
|
||||
|
||||
if (!is_array($parameters)) {
|
||||
$parameters = array();
|
||||
}
|
||||
if (empty($parameters['assetdepreciationoptions'])) {
|
||||
$parameters['assetdepreciationoptions'] = &$assetdepreciationoptions;
|
||||
}
|
||||
$reshook = $hookmanager->executeHooks('formAssetDeprecationOptions', $parameters, $object, $action);
|
||||
print $hookmanager->resPrint;
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
$class_type = get_class($object) == 'Asset' ? 0 : 1;
|
||||
foreach ($assetdepreciationoptions->deprecation_options_fields as $mode_key => $mode_info) {
|
||||
if (!empty($mode_info['enabled_field'])) {
|
||||
$info = explode(':', $mode_info['enabled_field']);
|
||||
if ($assetdepreciationoptions->deprecation_options[$info[0]][$info[1]] != $info[2]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$assetdepreciationoptions->setInfosForMode($mode_key, $class_type, true);
|
||||
|
||||
print load_fiche_titre($langs->trans($mode_info['label']), '', '');
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">' . "\n";
|
||||
$mode_info['fields'] = dol_sort_array($mode_info['fields'], 'position');
|
||||
foreach ($mode_info['fields'] as $field_key => $field_info) {
|
||||
if (!empty($field_info['enabled_field'])) {
|
||||
$info = explode(':', $field_info['enabled_field']);
|
||||
if ($assetdepreciationoptions->deprecation_options[$info[0]][$info[1]] != $info[2]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// Discard if extrafield is a hidden field on form
|
||||
if (abs($field_info['visible']) != 1 && abs($field_info['visible']) != 3 && abs($field_info['visible']) != 4 && abs($field_info['visible']) != 5) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists('enabled', $field_info) && isset($field_info['enabled']) && !verifCond($field_info['enabled'])) {
|
||||
continue; // We don't want this field
|
||||
}
|
||||
if (!empty($field_info['column_break'])) {
|
||||
print '</table>';
|
||||
|
||||
// We close div and reopen for second column
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
}
|
||||
|
||||
$key = $mode_key . '_' . $field_key;
|
||||
$value = $assetdepreciationoptions->deprecation_options[$mode_key][$field_key];
|
||||
|
||||
print '<tr class="field_' . $key . '"><td';
|
||||
print ' class="' . (empty($field_info['tdcss']) ? 'titlefield' : $field_info['tdcss']) . ' fieldname_' . $key;
|
||||
if ($field_info['type'] == 'text' || $field_info['type'] == 'html') {
|
||||
print ' tdtop';
|
||||
}
|
||||
print '">';
|
||||
if (!empty($field_info['help'])) {
|
||||
print $form->textwithpicto($langs->trans($field_info['label']), $langs->trans($field_info['help']));
|
||||
} else {
|
||||
if (isset($field_info['copytoclipboard']) && $field_info['copytoclipboard'] == 1) {
|
||||
print showValueWithClipboardCPButton($value, 0, $langs->transnoentitiesnoconv($field_info['label']));
|
||||
} else {
|
||||
print $langs->trans($field_info['label']);
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
print '<td class="valuefield fieldname_' . $key;
|
||||
if ($field_info['type'] == 'text') {
|
||||
print ' wordbreak';
|
||||
}
|
||||
if (!empty($field_info['cssview'])) {
|
||||
print ' ' . $field_info['cssview'];
|
||||
}
|
||||
print '">';
|
||||
if (in_array($field_info['type'], array('text', 'html'))) {
|
||||
print '<div class="longmessagecut">';
|
||||
}
|
||||
if ($field_key == 'lang') {
|
||||
$langs->load("languages");
|
||||
$labellang = ($value ? $langs->trans('Language_' . $value) : '');
|
||||
print picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"');
|
||||
print $labellang;
|
||||
} else {
|
||||
if (isset($field_info['copytoclipboard']) && $field_info['copytoclipboard'] == 2) {
|
||||
$out = $assetdepreciationoptions->showOutputField($field_info, $field_key, $value, '', '', $mode_key . '_', 0);
|
||||
print showValueWithClipboardCPButton($out, 0, $out);
|
||||
} else {
|
||||
print $assetdepreciationoptions->showOutputField($field_info, $field_key, $value, '', '', $mode_key . '_', 0);
|
||||
}
|
||||
}
|
||||
if (in_array($field_info['type'], array('text', 'html'))) {
|
||||
print '</div>';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
print '<div class="clearboth"></div>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!-- END PHP TEMPLATE depreciation_options_view.tpl.php -->
|
||||
154
htdocs/asset/tpl/depreciation_view.tpl.php
Normal file
154
htdocs/asset/tpl/depreciation_view.tpl.php
Normal file
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Show extrafields. It also show fields from hook formAssetAccountancyCode. Need to have following variables defined:
|
||||
* $object (asset, assetmodel, ...)
|
||||
* $assetaccountancycodes
|
||||
* $action
|
||||
* $conf
|
||||
* $langs
|
||||
*
|
||||
* $parameters
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($object) || !is_object($object)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!is_object($form)) {
|
||||
$form = new Form($db);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!-- BEGIN PHP TEMPLATE depreciation_options_view.tpl.php -->
|
||||
<?php
|
||||
|
||||
if (!is_array($parameters)) {
|
||||
$parameters = array();
|
||||
}
|
||||
if (empty($parameters['assetdepreciationoptions'])) {
|
||||
$parameters['assetdepreciationoptions'] = &$assetdepreciationoptions;
|
||||
}
|
||||
$reshook = $hookmanager->executeHooks('formAssetDeprecationOptions', $parameters, $object, $action);
|
||||
print $hookmanager->resPrint;
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
$class_type = get_class($object) == 'Asset' ? 0 : 1;
|
||||
foreach ($assetdepreciationoptions->deprecation_options_fields as $mode_key => $mode_info) {
|
||||
if (!empty($mode_info['enabled_field'])) {
|
||||
$info = explode(':', $mode_info['enabled_field']);
|
||||
if ($assetdepreciationoptions->deprecation_options[$info[0]][$info[1]] != $info[2]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$assetdepreciationoptions->setInfosForMode($mode_key, $class_type, true);
|
||||
|
||||
print load_fiche_titre($langs->trans($mode_info['label']), '', '');
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">' . "\n";
|
||||
$mode_info['fields'] = dol_sort_array($mode_info['fields'], 'position');
|
||||
foreach ($mode_info['fields'] as $field_key => $field_info) {
|
||||
if (!empty($field_info['enabled_field'])) {
|
||||
$info = explode(':', $field_info['enabled_field']);
|
||||
if ($assetdepreciationoptions->deprecation_options[$info[0]][$info[1]] != $info[2]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// Discard if extrafield is a hidden field on form
|
||||
if (abs($field_info['visible']) != 1 && abs($field_info['visible']) != 3 && abs($field_info['visible']) != 4 && abs($field_info['visible']) != 5) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists('enabled', $field_info) && isset($field_info['enabled']) && !verifCond($field_info['enabled'])) {
|
||||
continue; // We don't want this field
|
||||
}
|
||||
if (!empty($field_info['column_break'])) {
|
||||
print '</table>';
|
||||
|
||||
// We close div and reopen for second column
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
}
|
||||
|
||||
$key = $mode_key . '_' . $field_key;
|
||||
$value = $assetdepreciationoptions->deprecation_options[$mode_key][$field_key];
|
||||
|
||||
print '<tr class="field_' . $key . '"><td';
|
||||
print ' class="' . (empty($field_info['tdcss']) ? 'titlefield' : $field_info['tdcss']) . ' fieldname_' . $key;
|
||||
if ($field_info['type'] == 'text' || $field_info['type'] == 'html') {
|
||||
print ' tdtop';
|
||||
}
|
||||
print '">';
|
||||
if (!empty($field_info['help'])) {
|
||||
print $form->textwithpicto($langs->trans($field_info['label']), $langs->trans($field_info['help']));
|
||||
} else {
|
||||
if (isset($field_info['copytoclipboard']) && $field_info['copytoclipboard'] == 1) {
|
||||
print showValueWithClipboardCPButton($value, 0, $langs->transnoentitiesnoconv($field_info['label']));
|
||||
} else {
|
||||
print $langs->trans($field_info['label']);
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
print '<td class="valuefield fieldname_' . $key;
|
||||
if ($field_info['type'] == 'text') {
|
||||
print ' wordbreak';
|
||||
}
|
||||
if (!empty($field_info['cssview'])) {
|
||||
print ' ' . $field_info['cssview'];
|
||||
}
|
||||
print '">';
|
||||
if (in_array($field_info['type'], array('text', 'html'))) {
|
||||
print '<div class="longmessagecut">';
|
||||
}
|
||||
if ($field_key == 'lang') {
|
||||
$langs->load("languages");
|
||||
$labellang = ($value ? $langs->trans('Language_' . $value) : '');
|
||||
print picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"');
|
||||
print $labellang;
|
||||
} else {
|
||||
if (isset($field_info['copytoclipboard']) && $field_info['copytoclipboard'] == 2) {
|
||||
$out = $assetdepreciationoptions->showOutputField($field_info, $field_key, $value, '', '', $mode_key . '_', 0);
|
||||
print showValueWithClipboardCPButton($out, 0, $out);
|
||||
} else {
|
||||
print $assetdepreciationoptions->showOutputField($field_info, $field_key, $value, '', '', $mode_key . '_', 0);
|
||||
}
|
||||
}
|
||||
if (in_array($field_info['type'], array('text', 'html'))) {
|
||||
print '</div>';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
print '<div class="clearboth"></div>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!-- END PHP TEMPLATE depreciation_options_view.tpl.php -->
|
||||
81
htdocs/asset/tpl/linkedobjectblock.tpl.php
Normal file
81
htdocs/asset/tpl/linkedobjectblock.tpl.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($conf) || !is_object($conf)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
|
||||
print "<!-- BEGIN PHP TEMPLATE commande/tpl/linkedopjectblock.tpl.php -->\n";
|
||||
|
||||
global $user;
|
||||
global $noMoreLinkedObjectBlockAfter;
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->load("assets");
|
||||
|
||||
$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
|
||||
|
||||
$total = 0;
|
||||
$ilink = 0;
|
||||
foreach ($linkedObjectBlock as $key => $objectlink) {
|
||||
$ilink++;
|
||||
|
||||
$trclass = 'oddeven';
|
||||
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
|
||||
$trclass .= ' liste_sub_total';
|
||||
}
|
||||
echo '<tr class="'.$trclass.'" >';
|
||||
echo '<td class="linkedcol-element" >'.$langs->trans("Asset");
|
||||
if (!empty($showImportButton) && !empty($conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)) {
|
||||
print '<a class="objectlinked_importbtn" href="'.$objectlink->getNomUrl(0, '', 0, 1).'&action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a';
|
||||
}
|
||||
echo '</td>';
|
||||
echo '<td class="linkedcol-name nowraponall" >'.$objectlink->getNomUrl(1).'</td>';
|
||||
echo '<td class="linkedcol-ref" align="center">'.$objectlink->label.'</td>';
|
||||
echo '<td class="linkedcol-date" align="center">'.dol_print_date($objectlink->date_start, 'day').'</td>';
|
||||
echo '<td class="linkedcol-amount right">';
|
||||
if ($user->rights->asset->read) {
|
||||
$total = $total + $objectlink->acquisition_value_ht;
|
||||
echo price($objectlink->acquisition_value_ht);
|
||||
}
|
||||
echo '</td>';
|
||||
echo '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>';
|
||||
echo '<td class="linkedcol-action right">';
|
||||
echo '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&token='.newToken().'&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a>';
|
||||
echo '</td>';
|
||||
echo "</tr>\n";
|
||||
}
|
||||
if (count($linkedObjectBlock) > 1) {
|
||||
echo '<tr class="liste_total '.(empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : '').'">';
|
||||
echo '<td>'.$langs->trans("Total").'</td>';
|
||||
echo '<td></td>';
|
||||
echo '<td class="center"></td>';
|
||||
echo '<td class="center"></td>';
|
||||
echo '<td class="right">'.price($total).'</td>';
|
||||
echo '<td class="right"></td>';
|
||||
echo '<td class="right"></td>';
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
echo "<!-- END PHP TEMPLATE -->\n";
|
||||
@ -1,608 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/asset/type.php
|
||||
* \ingroup asset
|
||||
* \brief Asset's type setup
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/asset/class/asset_type.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
}
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
}
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->load("assets");
|
||||
|
||||
$rowid = GETPOST('rowid', 'int');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
$type = GETPOST('type', 'alpha');
|
||||
|
||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) {
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "a.label";
|
||||
}
|
||||
|
||||
$label = GETPOST("label", "alpha");
|
||||
$accountancy_code_asset = GETPOST('accountancy_code_asset', 'string');
|
||||
$accountancy_code_depreciation_asset = GETPOST('accountancy_code_depreciation_asset', 'string');
|
||||
$accountancy_code_depreciation_expense = GETPOST('accountancy_code_depreciation_expense', 'string');
|
||||
$comment = GETPOST('comment', 'string');
|
||||
|
||||
// Security check
|
||||
$result = restrictedArea($user, 'asset', $rowid, 'asset_type');
|
||||
|
||||
$object = new AssetType($db);
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$type = "";
|
||||
$sall = "";
|
||||
}
|
||||
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('assettypecard', 'globalcard'));
|
||||
|
||||
$permissiontoadd = $user->rights->asset->setup_advance;
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($cancel) {
|
||||
$action = '';
|
||||
|
||||
if (!empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'add' && $user->rights->asset->write) {
|
||||
$object->label = trim($label);
|
||||
$object->accountancy_code_asset = trim($accountancy_code_asset);
|
||||
$object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset);
|
||||
$object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense);
|
||||
$object->note = trim($comment);
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (empty($object->label)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
|
||||
} else {
|
||||
$sql = "SELECT label FROM ".MAIN_DB_PREFIX."asset_type WHERE label='".$db->escape($object->label)."'";
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
}
|
||||
if ($num) {
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorLabelAlreadyExists", $login), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$id = $object->create($user);
|
||||
if ($id > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = 'create';
|
||||
}
|
||||
} else {
|
||||
$action = 'create';
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'update' && $user->rights->asset->write) {
|
||||
$object->fetch($rowid);
|
||||
|
||||
$object->oldcopy = clone $object;
|
||||
|
||||
$object->label = trim($label);
|
||||
$object->accountancy_code_asset = trim($accountancy_code_asset);
|
||||
$object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset);
|
||||
$object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense);
|
||||
$object->note = trim($comment);
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
$ret = $object->update($user);
|
||||
|
||||
if ($ret >= 0 && !count($object->errors)) {
|
||||
setEventMessages($langs->trans("AssetTypeModified"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$object->id);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($action == 'confirm_delete' && $user->rights->asset->write) {
|
||||
$object->fetch($rowid);
|
||||
$res = $object->delete();
|
||||
|
||||
if ($res > 0) {
|
||||
setEventMessages($langs->trans("AssetsTypeDeleted"), null, 'mesgs');
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($langs->trans("AssetsTypeCanNotBeDeleted"), null, 'errors');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$help_url = '';
|
||||
|
||||
llxHeader('', $langs->trans("AssetsTypeSetup"), $help_url);
|
||||
|
||||
|
||||
// List of asset type
|
||||
if (!$rowid && $action != 'create' && $action != 'edit') {
|
||||
//print dol_get_fiche_head('');
|
||||
|
||||
$sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d";
|
||||
$sql .= " WHERE d.entity IN (".getEntity('asset_type').")";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$nbtotalofrecords = $num;
|
||||
|
||||
$i = 0;
|
||||
|
||||
$param = '';
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
|
||||
$newcardbutton = dolGetButtonTitle($langs->trans('NewAssetType'), '', 'fa fa-plus-circle', dol_buildpath('/asset/type.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
|
||||
|
||||
print_barre_liste($langs->trans("AssetsTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit);
|
||||
|
||||
$moreforfilter = '';
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th>'.$langs->trans("Ref").'</th>';
|
||||
print '<th>'.$langs->trans("Label").'</th>';
|
||||
print '<th class="center">'.$langs->trans("AccountancyCodeAsset").'</th>';
|
||||
print '<th class="center">'.$langs->trans("AccountancyCodeDepreciationAsset").'</th>';
|
||||
print '<th class="center">'.$langs->trans("AccountancyCodeDepreciationExpense").'</th>';
|
||||
print '<th> </th>';
|
||||
print "</tr>\n";
|
||||
|
||||
$assettype = new AssetType($db);
|
||||
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$assettype->id = $objp->rowid;
|
||||
$assettype->ref = $objp->rowid;
|
||||
$assettype->label = $objp->rowid;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
print $assettype->getNomUrl(1);
|
||||
//<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a>
|
||||
print '</td>';
|
||||
print '<td>'.dol_escape_htmltag($objp->label).'</td>';
|
||||
|
||||
print '<td class="center">';
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch('', $objp->accountancy_code_asset, 1);
|
||||
|
||||
print $accountingaccount->getNomUrl(0, 1, 1, '', 0);
|
||||
} else {
|
||||
print $objp->accountancy_code_asset;
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print '<td class="center">';
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$accountingaccount2 = new AccountingAccount($db);
|
||||
$accountingaccount2->fetch('', $objp->accountancy_code_depreciation_asset, 1);
|
||||
|
||||
print $accountingaccount2->getNomUrl(0, 1, 1, '', 0);
|
||||
} else {
|
||||
print $objp->accountancy_code_depreciation_asset;
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print '<td class="center">';
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$accountingaccount3 = new AccountingAccount($db);
|
||||
$accountingaccount3->fetch('', $objp->accountancy_code_depreciation_expense, 1);
|
||||
|
||||
print $accountingaccount3->getNomUrl(0, 1, 1, '', 0);
|
||||
} else {
|
||||
print $objp->accountancy_code_depreciation_expense;
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
if ($user->rights->asset->write) {
|
||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
|
||||
} else {
|
||||
print '<td class="right"> </td>';
|
||||
}
|
||||
print "</tr>";
|
||||
$i++;
|
||||
}
|
||||
|
||||
// If no record found
|
||||
if ($num == 0) {
|
||||
$colspan = 6;
|
||||
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Creation mode */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
if ($action == 'create') {
|
||||
$object = new AssetType($db);
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$formaccounting = new FormAccounting($db);
|
||||
}
|
||||
|
||||
print load_fiche_titre($langs->trans("NewAssetType"), '', $object->picto);
|
||||
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
print dol_get_fiche_head('');
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
print '<tbody>';
|
||||
|
||||
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40"></td></tr>';
|
||||
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
// Accountancy_code_asset
|
||||
print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>';
|
||||
print '<td>';
|
||||
print $formaccounting->select_account($object->accountancy_code_asset, 'accountancy_code_asset', 1, '', 1, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Accountancy_code_depreciation_expense
|
||||
print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>';
|
||||
print '<td>';
|
||||
print $formaccounting->select_account($object->accountancy_code_depreciation_asset, 'accountancy_code_depreciation_asset', 1, '', 1, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Accountancy_code_depreciation_expense
|
||||
print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>';
|
||||
print '<td>';
|
||||
print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1);
|
||||
print '</td></tr>';
|
||||
} else // For external software
|
||||
{
|
||||
// Accountancy_code_asset
|
||||
print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>';
|
||||
print '<td><input name="accountancy_code_asset" class="maxwidth200" value="'.$object->accountancy_code_asset.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Accountancy_code_depreciation_asset
|
||||
print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>';
|
||||
print '<td><input name="accountancy_code_depreciation_asset" class="maxwidth200" value="'.$object->accountancy_code_depreciation_asset.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Accountancy_code_depreciation_expense
|
||||
print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>';
|
||||
print '<td><input name="accountancy_code_depreciation_expense" class="maxwidth200" value="'.$object->accountancy_code_depreciation_expense.'">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
|
||||
print '<textarea name="comment" wrap="soft" class="centpercent" rows="3"></textarea></td></tr>';
|
||||
|
||||
// Other attributes
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook)) {
|
||||
print $object->showOptionals($extrafields, 'create', $parameters);
|
||||
}
|
||||
print '<tbody>';
|
||||
print "</table>\n";
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print $form->buttonsSaveCancel("Add");
|
||||
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* View mode */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
if ($rowid > 0) {
|
||||
if ($action != 'edit') {
|
||||
$object = new AssetType($db);
|
||||
$object->fetch($rowid);
|
||||
$object->fetch_optionals();
|
||||
|
||||
/*
|
||||
* Confirmation suppression
|
||||
*/
|
||||
if ($action == 'delete') {
|
||||
print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id, $langs->trans("DeleteAnAssetType"), $langs->trans("ConfirmDeleteAssetType", $object->label), "confirm_delete", '', 0, 1);
|
||||
}
|
||||
|
||||
$head = asset_type_prepare_head($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'card', $langs->trans("AssetType"), -1, 'asset');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/asset/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
// Ref asset type
|
||||
$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', 0, 1);
|
||||
$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', null, null, '', 1);
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
print '<tr>';
|
||||
print '<td class="nowrap titlefieldcreate">';
|
||||
print $langs->trans("AccountancyCodeAsset");
|
||||
print '</td><td>';
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch('', $object->accountancy_code_asset, 1);
|
||||
|
||||
print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
|
||||
} else {
|
||||
print $object->accountancy_code_asset;
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td class="nowrap">';
|
||||
print $langs->trans("AccountancyCodeDepreciationAsset");
|
||||
print '</td><td>';
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$accountingaccount2 = new AccountingAccount($db);
|
||||
$accountingaccount2->fetch('', $object->accountancy_code_depreciation_asset, 1);
|
||||
|
||||
print $accountingaccount2->getNomUrl(0, 1, 1, '', 1);
|
||||
} else {
|
||||
print $object->accountancy_code_depreciation_asset;
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td class="nowrap">';
|
||||
print $langs->trans("AccountancyCodeDepreciationExpense");
|
||||
print '</td><td>';
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$accountingaccount3 = new AccountingAccount($db);
|
||||
$accountingaccount3->fetch('', $object->accountancy_code_depreciation_expense, 1);
|
||||
|
||||
print $accountingaccount3->getNomUrl(0, 1, 1, '', 1);
|
||||
} else {
|
||||
print $object->accountancy_code_depreciation_expense;
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
|
||||
print nl2br($object->note)."</td></tr>";
|
||||
|
||||
// Other attributes
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
/*
|
||||
* Buttons
|
||||
*/
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
// Edit
|
||||
if ($user->rights->asset->write) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&rowid='.((int) $object->id).'">'.$langs->trans("Modify").'</a></div>';
|
||||
}
|
||||
|
||||
// Delete
|
||||
if ($user->rights->asset->write) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.((int) $object->id).'">'.$langs->trans("DeleteType").'</a></div>';
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Edition mode */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if ($action == 'edit') {
|
||||
$object = new AssetType($db);
|
||||
$object->fetch($rowid);
|
||||
$object->fetch_optionals();
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$formaccounting = new FormAccounting($db);
|
||||
}
|
||||
|
||||
$head = asset_type_prepare_head($object);
|
||||
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="rowid" value="'.$object->id.'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
print dol_get_fiche_head($head, 'card', $langs->trans("AssetsType"), -1, 'setup');
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
|
||||
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
// Accountancy_code_asset
|
||||
print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>';
|
||||
print '<td>';
|
||||
print $formaccounting->select_account($object->accountancy_code_asset, 'accountancy_code_asset', 1, '', 1, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Accountancy_code_depreciation_expense
|
||||
print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>';
|
||||
print '<td>';
|
||||
print $formaccounting->select_account($object->accountancy_code_depreciation_asset, 'accountancy_code_depreciation_asset', 1, '', 1, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Accountancy_code_depreciation_expense
|
||||
print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>';
|
||||
print '<td>';
|
||||
print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1);
|
||||
print '</td></tr>';
|
||||
} else // For external software
|
||||
{
|
||||
// Accountancy_code_asset
|
||||
print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>';
|
||||
print '<td><input name="accountancy_code_asset" class="maxwidth200" value="'.$object->accountancy_code_asset.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Accountancy_code_depreciation_asset
|
||||
print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationAsset").'</td>';
|
||||
print '<td><input name="accountancy_code_depreciation_asset" class="maxwidth200" value="'.$object->accountancy_code_depreciation_asset.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Accountancy_code_depreciation_expense
|
||||
print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeDepreciationExpense").'</td>';
|
||||
print '<td><input name="accountancy_code_depreciation_expense" class="maxwidth200" value="'.$object->accountancy_code_depreciation_expense.'">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
|
||||
print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">'.$object->note.'</textarea></td></tr>';
|
||||
|
||||
// Other attributes
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook)) {
|
||||
print $object->showOptionals($extrafields, 'edit', $parameters);
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print $form->buttonsSaveCancel();
|
||||
|
||||
print "</form>";
|
||||
}
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -765,8 +765,8 @@ if (empty($reshook)) {
|
||||
|
||||
// Define special_code for special lines
|
||||
$special_code = GETPOST('special_code', 'int');
|
||||
if (!GETPOST('qty', 'alpha')) {
|
||||
$special_code = 3;
|
||||
if ($special_code == 3) {
|
||||
$special_code = 0; // Options should not exists on invoices
|
||||
}
|
||||
|
||||
/*$line = new FactureLigne($db);
|
||||
|
||||
@ -743,7 +743,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// On verifie si la facture a des paiements
|
||||
// We check if invoice has payments
|
||||
$sql = 'SELECT pf.amount';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf';
|
||||
$sql .= ' WHERE pf.fk_facture = '.((int) $object->id);
|
||||
@ -993,7 +993,7 @@ if (empty($reshook)) {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercancreate) {
|
||||
} elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercanissuepayment) {
|
||||
// Delete payment
|
||||
$object->fetch($id);
|
||||
if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0) {
|
||||
@ -2397,9 +2397,9 @@ if (empty($reshook)) {
|
||||
}
|
||||
|
||||
// Define special_code for special lines
|
||||
$special_code = GETPOST('special_code');
|
||||
if (!GETPOST('qty')) {
|
||||
$special_code = 3;
|
||||
$special_code = GETPOST('special_code', 'int');
|
||||
if ($special_code == 3) {
|
||||
$special_code = 0; // Options should not exists on invoices
|
||||
}
|
||||
|
||||
$line = new FactureLigne($db);
|
||||
@ -2925,6 +2925,9 @@ if ($action == 'create') {
|
||||
if (empty($mode_reglement_id)) {
|
||||
$mode_reglement_id = $soc->mode_reglement_id;
|
||||
}
|
||||
if (empty($fk_account)) {
|
||||
$fk_account = $soc->fk_account;
|
||||
}
|
||||
if (!$remise_percent) {
|
||||
$remise_percent = $soc->remise_percent;
|
||||
}
|
||||
@ -3032,6 +3035,9 @@ if ($action == 'create') {
|
||||
$mode_reglement_id = GETPOST("mode_reglement_id", 'int');
|
||||
}
|
||||
|
||||
// when bank account is empty (means not override by payment mode form a other object, like third-party), try to use default value
|
||||
$fk_account = GETPOSTISSET("fk_account") ? GETPOST("fk_account", 'int') : $fk_account;
|
||||
|
||||
if (!empty($soc->id)) {
|
||||
$absolute_discount = $soc->getAvailableDiscounts();
|
||||
}
|
||||
@ -3638,8 +3644,8 @@ if ($action == 'create') {
|
||||
// Bank Account
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
print '<tr><td>'.$langs->trans('BankAccount').'</td><td colspan="2">';
|
||||
$fk_account = GETPOSTISSET('fk_account') ? GETPOST('fk_account', 'int') : $fk_account;
|
||||
print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes(($fk_account < 0 ? '' : $fk_account), 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1);
|
||||
print img_picto('', 'bank_account', 'class="pictofixedwidth"');
|
||||
print $form->select_comptes(($fk_account < 0 ? '' : $fk_account), 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
@ -2643,6 +2643,7 @@ class Facture extends CommonInvoice
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
|
||||
$productStatic = new Product($this->db);
|
||||
$warehouseStatic = new Entrepot($this->db);
|
||||
$productbatch = new ProductBatch($this->db);
|
||||
}
|
||||
|
||||
$now = dol_now();
|
||||
@ -2785,7 +2786,7 @@ class Facture extends CommonInvoice
|
||||
$sortorder = 'ASC,ASC,ASC,ASC';
|
||||
}
|
||||
|
||||
$resBatchList = Productbatch::findAllForProduct($this->db, $productStatic->id, $idwarehouse, (!empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER) ? null : 0), $sortfield, $sortorder);
|
||||
$resBatchList = $productbatch->findAllForProduct($productStatic->id, $idwarehouse, (!empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER) ? null : 0), $sortfield, $sortorder);
|
||||
if (!is_array($resBatchList)) {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
|
||||
@ -75,6 +75,12 @@ $hookmanager->initHooks(array('paiementcard', 'globalcard'));
|
||||
|
||||
$formquestion = array();
|
||||
|
||||
$usercanissuepayment = !empty($user->rights->facture->paiement);
|
||||
|
||||
$fieldid = 'rowid';
|
||||
$isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0);
|
||||
$result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $fieldid, $isdraft);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -87,7 +93,7 @@ if ($reshook < 0) {
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) {
|
||||
if (($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) && $usercanissuepayment) {
|
||||
$error = 0;
|
||||
|
||||
$datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
|
||||
@ -202,7 +208,7 @@ if (empty($reshook)) {
|
||||
/*
|
||||
* Action confirm_paiement
|
||||
*/
|
||||
if ($action == 'confirm_paiement' && $confirm == 'yes') {
|
||||
if ($action == 'confirm_paiement' && $confirm == 'yes' && $usercanissuepayment) {
|
||||
$error = 0;
|
||||
|
||||
$datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
|
||||
@ -486,7 +492,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '<td><span class="fieldrequired">'.$langs->trans('AccountToDebit').'</span></td>';
|
||||
}
|
||||
print '<td>';
|
||||
$form->select_comptes($accountid, 'accountid', 0, '', 2);
|
||||
print $form->select_comptes($accountid, 'accountid', 0, '', 2, '', 0, '', 1);
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td> </td>';
|
||||
|
||||
@ -64,6 +64,8 @@ if ($socid && $socid != $object->thirdparty->id) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -191,6 +193,39 @@ if ($action == 'setdatep' && GETPOST('datepday')) {
|
||||
setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors');
|
||||
}
|
||||
}
|
||||
if ($action == 'createbankpayment' && !empty($user->rights->facture->paiement)) {
|
||||
$db->begin();
|
||||
|
||||
// Create the record into bank for the amount of payment $object
|
||||
if (!$error) {
|
||||
$label = '(CustomerInvoicePayment)';
|
||||
if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) {
|
||||
$label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note
|
||||
}
|
||||
|
||||
$bankaccountid = GETPOST('accountid', 'int');
|
||||
if ($bankaccountid > 0) {
|
||||
$object->paiementcode = $object->type_code;
|
||||
$object->amounts = $object->getAmountsArray();
|
||||
|
||||
$result = $object->addPaymentToBank($user, 'payment', $label, $bankaccountid, '', '');
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -315,7 +350,37 @@ if (!empty($conf->banque->enabled)) {
|
||||
print $bankline->getNomUrl(1, 0, 'showconciliatedandaccounted');
|
||||
} else {
|
||||
$langs->load("admin");
|
||||
print '<span class="opacitymedium">'.$langs->trans("NoRecordFoundIBankcAccount", $langs->transnoentitiesnoconv("Module85Name")).'</span>';
|
||||
print '<span class="opacitymedium">';
|
||||
print $langs->trans("NoRecordFoundIBankcAccount", $langs->transnoentitiesnoconv("Module85Name"));
|
||||
print '</span>';
|
||||
if (!empty($user->rights->facture->paiement)) {
|
||||
// Try to guess $bankaccountidofinvoices that is ID of bank account defined on invoice.
|
||||
// Return null if not found, return 0 if it has different value for at least 2 invoices, return the value if same on all invoices where a bank is defined.
|
||||
$amountofpayments = $object->getAmountsArray();
|
||||
$bankaccountidofinvoices = null;
|
||||
foreach ($amountofpayments as $idinvoice => $amountofpayment) {
|
||||
$tmpinvoice = new Facture($db);
|
||||
$tmpinvoice->fetch($idinvoice);
|
||||
if ($tmpinvoice->fk_account > 0 && $bankaccountidofinvoices !== 0) {
|
||||
if (is_null($bankaccountidofinvoices)) {
|
||||
$bankaccountidofinvoices = $tmpinvoice->fk_account;
|
||||
} elseif ($bankaccountidofinvoices != $tmpinvoice->fk_account) {
|
||||
$bankaccountidofinvoices = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '<form method="POST" name="createbankpayment">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="createbankpayment">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
print ' '.$langs->trans("ToCreateRelatedRecordIntoBank").': ';
|
||||
print $form->select_comptes($bankaccountidofinvoices, 'accountid', 0, '', 2, '', 0, '', 1);
|
||||
//print '<span class="opacitymedium">';
|
||||
print '<input type="submit" class="button small smallpaddingimp" name="createbankpayment" value="'.$langs->trans("ClickHere").'">';
|
||||
//print '</span>';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -82,12 +82,12 @@ class Paiement extends CommonObject
|
||||
public $paiementcode; // Code of payment.
|
||||
|
||||
/**
|
||||
* @var string type libelle
|
||||
* @var string Type of payment label
|
||||
*/
|
||||
public $type_label;
|
||||
|
||||
/**
|
||||
* @var string type code
|
||||
* @var string Type of payment code (seems duplicate with $paiementcode);
|
||||
*/
|
||||
public $type_code;
|
||||
|
||||
@ -585,16 +585,19 @@ class Paiement extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$this->fk_account = $accountid;
|
||||
|
||||
dol_syslog("addPaymentToBank ".$user->id.", ".$mode.", ".$label.", ".$this->fk_account.", ".$emetteur_nom.", ".$emetteur_banque);
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
dol_syslog("$user->id, $mode, $label, $this->fk_account, $emetteur_nom, $emetteur_banque");
|
||||
|
||||
$acc = new Account($this->db);
|
||||
$result = $acc->fetch($this->fk_account);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$totalamount = $this->amount;
|
||||
if (empty($totalamount)) {
|
||||
@ -951,6 +954,7 @@ class Paiement extends CommonObject
|
||||
*
|
||||
* @param string $filter Filter
|
||||
* @return int|array <0 if KO or array of invoice id
|
||||
* @see getAmountsArray()
|
||||
*/
|
||||
public function getBillsArray($filter = '')
|
||||
{
|
||||
@ -984,6 +988,7 @@ class Paiement extends CommonObject
|
||||
* Return list of amounts of payments.
|
||||
*
|
||||
* @return int|array Array of amount of payments
|
||||
* @see getBillsArray()
|
||||
*/
|
||||
public function getAmountsArray()
|
||||
{
|
||||
|
||||
@ -149,31 +149,7 @@ class CMailFile
|
||||
}
|
||||
}
|
||||
|
||||
// Add autocopy to if not already in $to (Note: Adding bcc for specific modules are also done from pages)
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) && !preg_match('/'.preg_quote($conf->global->MAIN_MAIL_AUTOCOPY_TO, '/').'/i', $to)) {
|
||||
$addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
|
||||
}
|
||||
|
||||
$this->subject = $subject;
|
||||
$this->addr_to = $to;
|
||||
$this->addr_from = $from;
|
||||
$this->msg = $msg;
|
||||
$this->filename_list = $filename_list;
|
||||
$this->mimetype_list = $mimetype_list;
|
||||
$this->mimefilename_list = $mimefilename_list;
|
||||
$this->addr_cc = $addr_cc;
|
||||
$this->addr_bcc = $addr_bcc;
|
||||
$this->deliveryreceipt = $deliveryreceipt;
|
||||
if (empty($replyto)) {
|
||||
$replyto = $from;
|
||||
}
|
||||
$this->reply_to = $replyto;
|
||||
$this->errors_to = $errors_to;
|
||||
$this->trackid = $trackid;
|
||||
$this->sendcontext = $sendcontext;
|
||||
$this->filename_list = $filename_list;
|
||||
$this->mimetype_list = $mimetype_list;
|
||||
$this->mimefilename_list = $mimefilename_list;
|
||||
|
||||
// Define this->sendmode
|
||||
$this->sendmode = '';
|
||||
@ -186,10 +162,7 @@ class CMailFile
|
||||
}
|
||||
}
|
||||
if (empty($this->sendmode)) {
|
||||
$this->sendmode = $conf->global->MAIN_MAIL_SENDMODE;
|
||||
}
|
||||
if (empty($this->sendmode)) {
|
||||
$this->sendmode = 'mail';
|
||||
$this->sendmode = (!empty($conf->global->MAIN_MAIL_SENDMODE) ? $conf->global->MAIN_MAIL_SENDMODE : 'mail');
|
||||
}
|
||||
|
||||
// We define end of line (RFC 821).
|
||||
@ -283,15 +256,25 @@ class CMailFile
|
||||
$addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
|
||||
}
|
||||
|
||||
$this->subject = $subject;
|
||||
$this->addr_to = $to;
|
||||
$this->addr_from = $from;
|
||||
$this->msg = $msg;
|
||||
$this->filename_list = $filename_list;
|
||||
$this->mimetype_list = $mimetype_list;
|
||||
$this->mimefilename_list = $mimefilename_list;
|
||||
$this->addr_cc = $addr_cc;
|
||||
$this->addr_bcc = $addr_bcc;
|
||||
$this->reply_to = $replyto;
|
||||
$this->addr_from = $from;
|
||||
$this->subject = $subject;
|
||||
$this->errors_to = $errors_to;
|
||||
$this->deliveryreceipt = $deliveryreceipt;
|
||||
if (empty($replyto)) {
|
||||
$replyto = $from;
|
||||
}
|
||||
$this->reply_to = $replyto;
|
||||
$this->errors_to = $errors_to;
|
||||
$this->trackid = $trackid;
|
||||
$this->filename_list = $filename_list;
|
||||
$this->mimetype_list = $mimetype_list;
|
||||
$this->mimefilename_list = $mimefilename_list;
|
||||
|
||||
if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) {
|
||||
$this->addr_to = $conf->global->MAIN_MAIL_FORCE_SENDTO;
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2012-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2015-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2015-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2016 Bahfir abbes <dolipar@dolipar.org>
|
||||
* Copyright (C) 2017 ATM Consulting <support@atm-consulting.fr>
|
||||
* Copyright (C) 2017-2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
@ -3675,7 +3675,7 @@ abstract class CommonObject
|
||||
|
||||
// Elements of the core modules which have `$module` property but may to which we don't want to prefix module part to the element name for finding the linked object in llx_element_element.
|
||||
// It's because an entry for this element may be exist in llx_element_element before this modification (version <=14.2) and ave named only with their element name in fk_source or fk_target.
|
||||
$coremodule = array('knowledgemanagement', 'partnership', 'workstation', 'ticket', 'recruitment', 'eventorganization');
|
||||
$coremodule = array('knowledgemanagement', 'partnership', 'workstation', 'ticket', 'recruitment', 'eventorganization', 'asset');
|
||||
// Add module part to target type if object has $module property and isn't in core modules.
|
||||
$targettype = ((!empty($this->module) && ! in_array($this->module, $coremodule)) ? $this->module.'_' : '').$this->element;
|
||||
|
||||
@ -6697,7 +6697,7 @@ abstract class CommonObject
|
||||
if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, !empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%');
|
||||
$out = $doleditor->Create(1);
|
||||
$out = $doleditor->Create(1, '', true, '', '', $moreparam, $morecss);
|
||||
} else {
|
||||
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').'>';
|
||||
}
|
||||
@ -7717,7 +7717,7 @@ abstract class CommonObject
|
||||
if (empty($reshook)) {
|
||||
if (key_exists('label', $extrafields->attributes[$this->table_element]) && is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label']) > 0) {
|
||||
$out .= "\n";
|
||||
$out .= '<!-- showOptionals --> ';
|
||||
$out .= '<!-- commonobject:showOptionals --> ';
|
||||
$out .= "\n";
|
||||
|
||||
$extrafields_collapse_num = '';
|
||||
|
||||
@ -126,9 +126,11 @@ class DolEditor
|
||||
* @param boolean $disallowAnyContent Disallow to use any content. true=restrict to a predefined list of allowed elements. Used by CKEditor only.
|
||||
* @param string $titlecontent Show title content before editor area. Used by ACE editor only.
|
||||
* @param string $option For ACE editor, set the source language ('html', 'php', 'javascript', ...)
|
||||
* @param string $moreparam Add extra tags to the textarea
|
||||
* @param string $morecss Add extra css to the textarea
|
||||
* @return void|string
|
||||
*/
|
||||
public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '')
|
||||
public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '', $moreparam = '', $morecss = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs;
|
||||
@ -146,7 +148,7 @@ class DolEditor
|
||||
//$out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" '.($this->readonly?' disabled':'').' rows="'.$this->rows.'"'.(preg_match('/%/',$this->cols)?' style="margin-top: 5px; width: '.$this->cols.'"':' cols="'.$this->cols.'"').' class="flat">';
|
||||
// TODO We do not put the 'disabled' tag because on a read form, it change style with grey.
|
||||
//print $this->content;
|
||||
$out .= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'"'.(preg_match('/%/', $this->cols) ? ' style="margin-top: 5px; width: '.$this->cols.'"' : ' cols="'.$this->cols.'"').' class="flat">';
|
||||
$out .= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'"'.(preg_match('/%/', $this->cols) ? ' style="margin-top: 5px; width: '.$this->cols.'"' : ' cols="'.$this->cols.'"').' '.($moreparam ? $moreparam : '').' class="flat '.$morecss.'">';
|
||||
$out .= htmlspecialchars($this->content);
|
||||
$out .= '</textarea>';
|
||||
|
||||
|
||||
@ -1886,17 +1886,19 @@ class ExtraFields
|
||||
$out = '<'.$tagtype.' id="trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'" class="trextrafieldseparator trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'">';
|
||||
$out .= '<'.$tagtype_dyn.' '.(!empty($colspan)?'colspan="' . $colspan . '"':'').'>';
|
||||
// Some js code will be injected here to manage the collapsing of extrafields
|
||||
$out .= '<span class="cursorpointer far fa-'.($expand_display ? 'minus' : 'plus').'-square"></span> ';
|
||||
$out .= '<span class="cursorpointer '.($extrafield_collapse_display_value == 0 ? 'fas fa-square' : 'far fa-'.(($expand_display ? 'minus' : 'plus').'-square')).'"></span> ';
|
||||
$out .= '<strong>';
|
||||
$out .= $langs->trans($this->attributes[$object->table_element]['label'][$key]);
|
||||
$out .= '</strong>';
|
||||
$out .= '</'.$tagtype_dyn.'>';
|
||||
$out .= '</'.$tagtype.'>';
|
||||
|
||||
$collapse_group = $key.(!empty($object->id) ? '_'.$object->id : '');
|
||||
//$extrafields_collapse_num = $this->attributes[$object->table_element]['pos'][$key].(!empty($object->id)?'_'.$object->id:'');
|
||||
|
||||
if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) {
|
||||
// Set the collapse_display status to cookie in priority or if ignorecollapsesetup is 1, if cookie and ignorecollapsesetup not defined, use the setup.
|
||||
$extrafields_collapse_num = $this->attributes[$object->table_element]['pos'][$key].(!empty($object->id)?'_'.$object->id:'');
|
||||
$this->expand_display[$extrafields_collapse_num] = $expand_display;
|
||||
$this->expand_display[$collapse_group] = $expand_display;
|
||||
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
$out .= '<!-- Add js script to manage the collapse/uncollapse of extrafields separators '.$key.' -->'."\n";
|
||||
@ -1904,15 +1906,15 @@ class ExtraFields
|
||||
$out .= 'jQuery(document).ready(function(){'."\n";
|
||||
if ($expand_display === false) {
|
||||
$out .= ' console.log("Inject js for the collapsing of extrafield '.$key.' - hide");'."\n";
|
||||
$out .= ' jQuery(".trextrafields_collapse'.$extrafields_collapse_num.'").hide();'."\n";
|
||||
$out .= ' jQuery(".trextrafields_collapse'.$collapse_group.'").hide();'."\n";
|
||||
} else {
|
||||
$out .= ' console.log("Inject js for collapsing of extrafield '.$key.' - keep visible and set cookie");'."\n";
|
||||
$out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.'=1; path='.$_SERVER["PHP_SELF"].'"'."\n";
|
||||
}
|
||||
$out .= ' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'").click(function(){'."\n";
|
||||
$out .= ' console.log("We click on collapse/uncollapse .trextrafields_collapse'.$extrafields_collapse_num.'");'."\n";
|
||||
$out .= ' jQuery(".trextrafields_collapse'.$extrafields_collapse_num.'").toggle(100, function(){'."\n";
|
||||
$out .= ' if (jQuery(".trextrafields_collapse'.$extrafields_collapse_num.'").is(":hidden")) {'."\n";
|
||||
$out .= ' console.log("We click on collapse/uncollapse .trextrafields_collapse'.$collapse_group.'");'."\n";
|
||||
$out .= ' jQuery(".trextrafields_collapse'.$collapse_group.'").toggle(100, function(){'."\n";
|
||||
$out .= ' if (jQuery(".trextrafields_collapse'.$collapse_group.'").is(":hidden")) {'."\n";
|
||||
$out .= ' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').' '.$tagtype_dyn.' span").addClass("fa-plus-square").removeClass("fa-minus-square");'."\n";
|
||||
$out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.'=0; path='.$_SERVER["PHP_SELF"].'"'."\n";
|
||||
$out .= ' } else {'."\n";
|
||||
@ -1924,6 +1926,8 @@ class ExtraFields
|
||||
$out .= '});'."\n";
|
||||
$out .= '</script>'."\n";
|
||||
}
|
||||
} else {
|
||||
$this->expand_display[$collapse_group] = 1;
|
||||
}
|
||||
|
||||
return $out;
|
||||
|
||||
@ -439,9 +439,10 @@ class FormAccounting extends Form
|
||||
* @param int|string $showempty Add an empty field
|
||||
* @param string $morecss More css
|
||||
* @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
|
||||
* @param string $labelhtmlname HTML name of label for autofill of account from name.
|
||||
* @return string String with HTML select
|
||||
*/
|
||||
public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth250', $usecache = '')
|
||||
public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth250', $usecache = '', $labelhtmlname = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
|
||||
@ -505,6 +506,19 @@ class FormAccounting extends Form
|
||||
|
||||
// Build select
|
||||
$out .= Form::selectarray($htmlname, $aux_account, $selectid, ($showempty ? (is_numeric($showempty) ? 1 : $showempty): 0), 0, 0, '', 0, 0, 0, '', $morecss, 1);
|
||||
//automatic filling if we give the name of the subledger_label input
|
||||
if (!empty($conf->use_javascript_ajax) && !empty($labelhtmlname)) {
|
||||
$out .= '<script>
|
||||
jQuery(document).ready(() => {
|
||||
$("#'.$htmlname.'").on("select2:select", function(e) {
|
||||
var regExp = /\(([^)]+)\)/;
|
||||
const match = regExp.exec(e.params.data.text);
|
||||
$(\'input[name="'.dol_escape_js($labelhtmlname).'"]\').val(match[1]);
|
||||
});
|
||||
});
|
||||
|
||||
</script>';
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
/* Copyright (C) 2018-2022 OpenDSI <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -26,7 +26,7 @@
|
||||
*
|
||||
* @return array head array with tabs
|
||||
*/
|
||||
function asset_admin_prepare_head()
|
||||
function assetAdminPrepareHead()
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
@ -43,90 +43,118 @@ function asset_admin_prepare_head()
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
//$this->tabs = array(
|
||||
// 'entity:+tabname:Title:@assets:/asset/mypage.php?id=__ID__'
|
||||
// 'entity:+tabname:Title:@asset:/asset/mypage.php?id=__ID__'
|
||||
//); // to add new tab
|
||||
//$this->tabs = array(
|
||||
// 'entity:-tabname:Title:@assets:/asset/mypage.php?id=__ID__'
|
||||
// 'entity:-tabname:Title:@asset:/asset/mypage.php?id=__ID__'
|
||||
//); // to remove a tab
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'assets_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'asset_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/asset/admin/assets_extrafields.php';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/asset/admin/asset_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$head[$h][2] = 'attributes';
|
||||
$head[$h][2] = 'asset_extrafields';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/asset/admin/assets_type_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsAssetsType");
|
||||
$head[$h][2] = 'attributes_type';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/asset/admin/assetmodel_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsAssetModel");
|
||||
$head[$h][2] = 'assetmodel_extrafields';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'assets_admin', 'remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'asset_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare admin pages header
|
||||
* Prepare array of tabs for Asset
|
||||
*
|
||||
* @param Contrat $object Object related to tabs
|
||||
* @return array head array with tabs
|
||||
* @param Asset $object Asset
|
||||
* @return array Array of tabs
|
||||
*/
|
||||
function asset_prepare_head(Asset $object)
|
||||
function assetPrepareHead(Asset $object)
|
||||
{
|
||||
global $db, $langs, $conf;
|
||||
|
||||
$langs->load("assets");
|
||||
$langs->load("assets", "admin");
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/asset/card.php?id='.$object->id;
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/card.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
if (empty($object->not_depreciated)) {
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/depreciation_options.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("AssetDepreciationOptions");
|
||||
$head[$h][2] = 'depreciation_options';
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/accountancy_codes.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("AssetAccountancyCodes");
|
||||
$head[$h][2] = 'accountancy_codes';
|
||||
$h++;
|
||||
|
||||
if (empty($object->not_depreciated)) {
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/depreciation.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("AssetDepreciation");
|
||||
$head[$h][2] = 'depreciation';
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (isset($object->disposal_date) && $object->disposal_date !== "") {
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/disposal.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("AssetDisposal");
|
||||
$head[$h][2] = 'disposal';
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
|
||||
$nbNote = 0;
|
||||
if (!empty($object->note_private)) {
|
||||
$nbNote++;
|
||||
}
|
||||
if (!empty($object->note_public)) {
|
||||
$nbNote++;
|
||||
}
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/note.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
if ($nbNote > 0) {
|
||||
$head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">' . $nbNote . '</span>' : '');
|
||||
}
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
|
||||
$upload_dir = $conf->asset->dir_output . "/asset/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks = Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/document.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles + $nbLinks) > 0) {
|
||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) . '</span>';
|
||||
}
|
||||
$head[$h][2] = 'document';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/agenda.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("Events");
|
||||
$head[$h][2] = 'agenda';
|
||||
$h++;
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
//$this->tabs = array(
|
||||
// 'entity:+tabname:Title:@assets:/asset/mypage.php?id=__ID__'
|
||||
// 'entity:+tabname:Title:@asset:/asset/mypage.php?id=__ID__'
|
||||
//); // to add new tab
|
||||
//$this->tabs = array(
|
||||
// 'entity:-tabname:Title:@assets:/asset/mypage.php?id=__ID__'
|
||||
// 'entity:-tabname:Title:@asset:/asset/mypage.php?id=__ID__'
|
||||
//); // to remove a tab
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets');
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->assets->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks = Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/asset/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles + $nbLinks) > 0) {
|
||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
|
||||
}
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
$nbNote = 0;
|
||||
if (!empty($object->note_private)) {
|
||||
$nbNote++;
|
||||
}
|
||||
if (!empty($object->note_public)) {
|
||||
$nbNote++;
|
||||
}
|
||||
$head[$h][0] = DOL_URL_ROOT.'/asset/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Notes");
|
||||
if ($nbNote > 0) {
|
||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
}
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/asset/info.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'asset');
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'asset', 'remove');
|
||||
|
||||
@ -134,30 +162,69 @@ function asset_prepare_head(Asset $object)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array head with list of tabs to view object informations
|
||||
* Prepare array of tabs for AssetModel
|
||||
*
|
||||
* @param AssetType $object Asset
|
||||
* @return array head
|
||||
* @param AssetModel $object AssetModel
|
||||
* @return array Array of tabs
|
||||
*/
|
||||
function asset_type_prepare_head(AssetType $object)
|
||||
function assetModelPrepareHead($object)
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
global $langs, $conf;
|
||||
|
||||
$langs->load("assets", "admin");
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/asset/type.php?rowid='.$object->id;
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/model/card.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/model/depreciation_options.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("AssetDepreciationOptions");
|
||||
$head[$h][2] = 'depreciation_options';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/model/accountancy_codes.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("AssetAccountancyCodes");
|
||||
$head[$h][2] = 'accountancy_codes';
|
||||
$h++;
|
||||
|
||||
if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
|
||||
$nbNote = 0;
|
||||
if (!empty($object->note_private)) {
|
||||
$nbNote++;
|
||||
}
|
||||
if (!empty($object->note_public)) {
|
||||
$nbNote++;
|
||||
}
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/model/note.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
if ($nbNote > 0) {
|
||||
$head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">' . $nbNote . '</span>' : '');
|
||||
}
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/model/agenda.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("Events");
|
||||
$head[$h][2] = 'agenda';
|
||||
$h++;
|
||||
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'assettype');
|
||||
//$this->tabs = array(
|
||||
// 'entity:+tabname:Title:@asset:/asset/mypage.php?id=__ID__'
|
||||
//); // to add new tab
|
||||
//$this->tabs = array(
|
||||
// 'entity:-tabname:Title:@asset:/asset/mypage.php?id=__ID__'
|
||||
//); // to remove a tab
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'assetmodel');
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'assettype', 'remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'assetmodel', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@ -10817,6 +10817,9 @@ function dolForgeCriteriaCallback($matches)
|
||||
$operand = preg_replace('/[^a-z0-9\._]/i', '', trim($tmp[0]));
|
||||
|
||||
$operator = strtoupper(preg_replace('/[^a-z<>=]/i', '', trim($tmp[1])));
|
||||
if ($operator == 'NOTLIKE') {
|
||||
$operator = 'NOT LIKE';
|
||||
}
|
||||
|
||||
$tmpescaped = trim($tmp[2]);
|
||||
$regbis = array();
|
||||
|
||||
@ -225,7 +225,14 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation =
|
||||
}
|
||||
|
||||
// Common check on ip (local and external)
|
||||
$arrayofmetadataserver = array('100.100.100.200' => 'Alibaba', '192.0.0.192'=> 'Oracle', '192.80.8.124'=>'Packet');
|
||||
// See list on https://tagmerge.com/gist/a7b9d57ff8ec11d63642f8778609a0b8
|
||||
// Not evasive url that ar enot IP are excluded by test on IP v4/v6 validity.
|
||||
$arrayofmetadataserver = array(
|
||||
'100.100.100.200' => 'Alibaba',
|
||||
'192.0.0.192' => 'Oracle',
|
||||
'192.80.8.124' => 'Packet',
|
||||
'100.88.222.5' => 'Tencent cloud',
|
||||
);
|
||||
foreach ($arrayofmetadataserver as $ipofmetadataserver => $nameofmetadataserver) {
|
||||
if ($iptocheck == $ipofmetadataserver) {
|
||||
$info['http_code'] = 400;
|
||||
|
||||
@ -410,7 +410,7 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t
|
||||
|
||||
// To enable when page exists
|
||||
if (empty($conf->global->ACCOUNTANCY_SHOW_DEVELOP_JOURNAL)) {
|
||||
if ($nature == 'various' || $nature == 'hasnew' || $nature == 'inventory') {
|
||||
if ($nature == 'hasnew' || $nature == 'inventory') {
|
||||
$nature = '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1332,7 +1332,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
|
||||
|
||||
// To enable when page exists
|
||||
if (empty($conf->global->ACCOUNTANCY_SHOW_DEVELOP_JOURNAL)) {
|
||||
if ($nature == 'various' || $nature == 'hasnew' || $nature == 'inventory') {
|
||||
if ($nature == 'hasnew' || $nature == 'inventory') {
|
||||
$nature = '';
|
||||
}
|
||||
}
|
||||
@ -1507,10 +1507,10 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
|
||||
$newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset', 100, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
|
||||
$newmenu->add("/asset/card.php?leftmenu=asset&action=create", $langs->trans("MenuNewAsset"), 1, $user->rights->asset->write);
|
||||
$newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->rights->asset->read);
|
||||
$newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type');
|
||||
if ($usemenuhider || empty($leftmenu) || preg_match('/asset_type/', $leftmenu)) {
|
||||
$newmenu->add("/asset/type.php?leftmenu=asset_type&action=create", $langs->trans("MenuNewTypeAssets"), 2, $user->rights->asset->setup_advance);
|
||||
$newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuListTypeAssets"), 2, $user->rights->asset->read);
|
||||
$newmenu->add("/asset/model/list.php?leftmenu=asset_model", $langs->trans("MenuAssetModels"), 1, (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read)), '', $mainmenu, 'asset_model');
|
||||
if ($usemenuhider || empty($leftmenu) || preg_match('/asset_model/', $leftmenu)) {
|
||||
$newmenu->add("/asset/model/card.php?leftmenu=asset_model&action=create", $langs->trans("MenuNewAssetModel"), 2, (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write)));
|
||||
$newmenu->add("/asset/model/list.php?leftmenu=asset_model", $langs->trans("MenuListAssetModels"), 2, (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
499
htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php
Normal file
499
htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php
Normal file
@ -0,0 +1,499 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2018-2021 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php
|
||||
* \ingroup asset
|
||||
* \brief File of class to build ODT documents for assets
|
||||
*/
|
||||
|
||||
dol_include_once('/asset/core/modules/asset/modules_asset.php');
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class to build documents using ODF templates generator
|
||||
*/
|
||||
class doc_generic_asset_odt extends ModelePDFAsset
|
||||
{
|
||||
/**
|
||||
* Issuer
|
||||
* @var Societe
|
||||
*/
|
||||
public $emetteur;
|
||||
|
||||
/**
|
||||
* @var array Minimum version of PHP required by module.
|
||||
* e.g.: PHP ≥ 5.6 = array(5, 6)
|
||||
*/
|
||||
public $phpmin = array(5, 6);
|
||||
|
||||
/**
|
||||
* @var string Dolibarr version of the loaded document
|
||||
*/
|
||||
public $version = 'dolibarr';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
global $conf, $langs, $mysoc;
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("main", "companies"));
|
||||
|
||||
$this->db = $db;
|
||||
$this->name = "ODT templates";
|
||||
$this->description = $langs->trans("DocumentModelOdt");
|
||||
$this->scandir = 'ASSET_ASSET_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
|
||||
|
||||
// Page size for A4 format
|
||||
$this->type = 'odt';
|
||||
$this->page_largeur = 0;
|
||||
$this->page_hauteur = 0;
|
||||
$this->format = array($this->page_largeur, $this->page_hauteur);
|
||||
$this->marge_gauche = 0;
|
||||
$this->marge_droite = 0;
|
||||
$this->marge_haute = 0;
|
||||
$this->marge_basse = 0;
|
||||
|
||||
$this->option_logo = 1; // Display logo
|
||||
$this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION
|
||||
$this->option_modereg = 0; // Display payment mode
|
||||
$this->option_condreg = 0; // Display payment terms
|
||||
$this->option_codeproduitservice = 0; // Display product-service code
|
||||
$this->option_multilang = 1; // Available in several languages
|
||||
$this->option_escompte = 0; // Displays if there has been a discount
|
||||
$this->option_credit_note = 0; // Support credit notes
|
||||
$this->option_freetext = 1; // Support add of a personalised text
|
||||
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
|
||||
|
||||
// Get source company
|
||||
$this->emetteur = $mysoc;
|
||||
if (!$this->emetteur->country_code) {
|
||||
$this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return description of a module
|
||||
*
|
||||
* @param Translate $langs Lang object to use for output
|
||||
* @return string Description
|
||||
*/
|
||||
public function info($langs)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("errors", "companies"));
|
||||
|
||||
$form = new Form($this->db);
|
||||
|
||||
$texte = $this->description.".<br>\n";
|
||||
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
|
||||
$texte .= '<input type="hidden" name="param1" value="ASSET_ASSET_ADDON_PDF_ODT_PATH">';
|
||||
$texte .= '<table class="nobordernopadding" width="100%">';
|
||||
|
||||
// List of directories area
|
||||
$texte .= '<tr><td>';
|
||||
$texttitle = $langs->trans("ListOfDirectories");
|
||||
$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->ASSET_ASSET_ADDON_PDF_ODT_PATH)));
|
||||
$listoffiles = array();
|
||||
foreach ($listofdir as $key => $tmpdir) {
|
||||
$tmpdir = trim($tmpdir);
|
||||
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
|
||||
if (!$tmpdir) {
|
||||
unset($listofdir[$key]);
|
||||
continue;
|
||||
}
|
||||
if (!is_dir($tmpdir)) {
|
||||
$texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
|
||||
} else {
|
||||
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
|
||||
if (count($tmpfiles)) {
|
||||
$listoffiles = array_merge($listoffiles, $tmpfiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
|
||||
// Add list of substitution keys
|
||||
$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
|
||||
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
|
||||
|
||||
$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
|
||||
$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
|
||||
$texte .= '<textarea class="flat" cols="60" name="value1">';
|
||||
$texte .= $conf->global->ASSET_ASSET_ADDON_PDF_ODT_PATH;
|
||||
$texte .= '</textarea>';
|
||||
$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
|
||||
$texte .= '<input type="submit" class="button small" name="Button"value="'.$langs->trans("Modify").'">';
|
||||
$texte .= '<br></div></div>';
|
||||
|
||||
// Scan directories
|
||||
$nbofiles = count($listoffiles);
|
||||
if (!empty($conf->global->ASSET_ASSET_ADDON_PDF_ODT_PATH)) {
|
||||
$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
|
||||
//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
|
||||
$texte .= count($listoffiles);
|
||||
//$texte.=$nbofiles?'</a>':'';
|
||||
$texte .= '</b>';
|
||||
}
|
||||
|
||||
if ($nbofiles) {
|
||||
$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
|
||||
foreach ($listoffiles as $file) {
|
||||
$texte .= '- '.$file['name'].' <a href="'.DOL_URL_ROOT.'/document.php?modulepart=doctemplates&file=asset_asset/'.urlencode(basename($file['name'])).'">'.img_picto('', 'listlight').'</a><br>';
|
||||
}
|
||||
$texte .= '</div>';
|
||||
}
|
||||
|
||||
$texte .= '</td>';
|
||||
|
||||
$texte .= '<td rowspan="2" class="tdtop hideonsmartphone">';
|
||||
$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
|
||||
$texte .= '</td>';
|
||||
$texte .= '</tr>';
|
||||
|
||||
$texte .= '</table>';
|
||||
$texte .= '</form>';
|
||||
|
||||
return $texte;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Function to build a document on disk using the generic odt module.
|
||||
*
|
||||
* @param Asset $object Object source to build document
|
||||
* @param Translate $outputlangs Lang output object
|
||||
* @param string $srctemplatepath Full path of source filename for generator using a template file
|
||||
* @param int $hidedetails Do not show line details
|
||||
* @param int $hidedesc Do not show desc
|
||||
* @param int $hideref Do not show ref
|
||||
* @return int 1 if OK, <=0 if KO
|
||||
*/
|
||||
public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $user, $langs, $conf, $mysoc, $hookmanager;
|
||||
|
||||
if (empty($srctemplatepath)) {
|
||||
dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Add odtgeneration hook
|
||||
if (!is_object($hookmanager)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
$hookmanager->initHooks(array('odtgeneration'));
|
||||
global $action;
|
||||
|
||||
if (!is_object($outputlangs)) {
|
||||
$outputlangs = $langs;
|
||||
}
|
||||
$sav_charset_output = $outputlangs->charset_output;
|
||||
$outputlangs->charset_output = 'UTF-8';
|
||||
|
||||
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
|
||||
|
||||
if ($conf->asset->dir_output) {
|
||||
// If $object is id instead of object
|
||||
if (!is_object($object)) {
|
||||
$id = $object;
|
||||
$object = new Asset($this->db);
|
||||
$result = $object->fetch($id);
|
||||
if ($result < 0) {
|
||||
dol_print_error($this->db, $object->error);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1];
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
if (!preg_match('/specimen/i', $objectref)) {
|
||||
$dir .= "/".$objectref;
|
||||
}
|
||||
$file = $dir."/".$objectref.".odt";
|
||||
|
||||
if (!file_exists($dir)) {
|
||||
if (dol_mkdir($dir) < 0) {
|
||||
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($dir)) {
|
||||
//print "srctemplatepath=".$srctemplatepath; // Src filename
|
||||
$newfile = basename($srctemplatepath);
|
||||
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
|
||||
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
|
||||
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
|
||||
$newfiletmp = $objectref.'_'.$newfiletmp;
|
||||
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (!empty($conf->global->MAIN_DOC_USE_TIMING)) {
|
||||
$format = $conf->global->MAIN_DOC_USE_TIMING;
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
|
||||
} else {
|
||||
$filename = $newfiletmp.'.'.$newfileformat;
|
||||
}
|
||||
$file = $dir.'/'.$filename;
|
||||
//print "newdir=".$dir;
|
||||
//print "newfile=".$newfile;
|
||||
//print "file=".$file;
|
||||
//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
|
||||
|
||||
dol_mkdir($conf->asset->dir_temp);
|
||||
if (!is_writable($conf->asset->dir_temp)) {
|
||||
$this->error = "Failed to write in temp directory ".$conf->asset->dir_temp;
|
||||
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// If CUSTOMER contact defined on order, we use it
|
||||
$usecontact = false;
|
||||
$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
|
||||
if (count($arrayidcontact) > 0) {
|
||||
$usecontact = true;
|
||||
$result = $object->fetch_contact($arrayidcontact[0]);
|
||||
}
|
||||
|
||||
// Recipient name
|
||||
$contactobject = null;
|
||||
if (!empty($usecontact)) {
|
||||
// We can use the company of contact instead of thirdparty company
|
||||
if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
|
||||
$object->contact->fetch_thirdparty();
|
||||
$socobject = $object->contact->thirdparty;
|
||||
$contactobject = $object->contact;
|
||||
} else {
|
||||
$socobject = $object->thirdparty;
|
||||
// if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
|
||||
$contactobject = $object->contact;
|
||||
}
|
||||
} else {
|
||||
$socobject = $object->thirdparty;
|
||||
}
|
||||
|
||||
// Make substitution
|
||||
$substitutionarray = array(
|
||||
'__FROM_NAME__' => $this->emetteur->name,
|
||||
'__FROM_EMAIL__' => $this->emetteur->email,
|
||||
'__TOTAL_TTC__' => $object->total_ttc,
|
||||
'__TOTAL_HT__' => $object->total_ht,
|
||||
'__TOTAL_VAT__' => $object->total_tva
|
||||
);
|
||||
complete_substitutions_array($substitutionarray, $langs, $object);
|
||||
// Call the ODTSubstitution hook
|
||||
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
|
||||
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
// Line of free text
|
||||
$newfreetext = '';
|
||||
$paramfreetext = 'ORDER_FREE_TEXT';
|
||||
if (!empty($conf->global->$paramfreetext)) {
|
||||
$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
|
||||
}
|
||||
|
||||
// Open and load template
|
||||
require_once ODTPHP_PATH.'odf.php';
|
||||
try {
|
||||
$odfHandler = new odf(
|
||||
$srctemplatepath,
|
||||
array(
|
||||
'PATH_TO_TMP' => $conf->asset->dir_temp,
|
||||
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
|
||||
'DELIMITER_LEFT' => '{',
|
||||
'DELIMITER_RIGHT' => '}'
|
||||
)
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
return -1;
|
||||
}
|
||||
// After construction $odfHandler->contentXml contains content and
|
||||
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
|
||||
// [!-- BEGIN lines --]*[!-- END lines --]
|
||||
//print html_entity_decode($odfHandler->__toString());
|
||||
//print exit;
|
||||
|
||||
|
||||
// Make substitutions into odt of freetext
|
||||
try {
|
||||
$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
|
||||
} catch (OdfException $e) {
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
|
||||
// Define substitution array
|
||||
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
|
||||
$array_objet = $this->get_substitutionarray_object($object, $outputlangs);
|
||||
$array_user = $this->get_substitutionarray_user($user, $outputlangs);
|
||||
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
|
||||
$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
|
||||
$array_other = $this->get_substitutionarray_other($outputlangs);
|
||||
// retrieve contact information for use in object as contact_xxx tags
|
||||
$array_thirdparty_contact = array();
|
||||
if ($usecontact && is_object($contactobject)) {
|
||||
$array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
|
||||
}
|
||||
|
||||
$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
|
||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||
|
||||
// Call the ODTSubstitution hook
|
||||
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
|
||||
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
foreach ($tmparray as $key => $value) {
|
||||
try {
|
||||
if (preg_match('/logo$/', $key)) {
|
||||
// Image
|
||||
if (file_exists($value)) {
|
||||
$odfHandler->setImage($key, $value);
|
||||
} else {
|
||||
$odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
|
||||
}
|
||||
} else {
|
||||
// Text
|
||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||
}
|
||||
} catch (OdfException $e) {
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
}
|
||||
// Replace tags of lines
|
||||
try {
|
||||
$foundtagforlines = 1;
|
||||
try {
|
||||
$listlines = $odfHandler->setSegment('lines');
|
||||
} catch (OdfException $e) {
|
||||
// We may arrive here if tags for lines not present into template
|
||||
$foundtagforlines = 0;
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
if ($foundtagforlines) {
|
||||
$linenumber = 0;
|
||||
foreach ($object->lines as $line) {
|
||||
$linenumber++;
|
||||
$tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber);
|
||||
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
|
||||
// Call the ODTSubstitutionLine hook
|
||||
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
|
||||
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
foreach ($tmparray as $key => $val) {
|
||||
try {
|
||||
$listlines->setVars($key, $val, true, 'UTF-8');
|
||||
} catch (OdfException $e) {
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
} catch (SegmentException $e) {
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
}
|
||||
$listlines->merge();
|
||||
}
|
||||
$odfHandler->mergeSegment($listlines);
|
||||
}
|
||||
} catch (OdfException $e) {
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($this->error, LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Replace labels translated
|
||||
$tmparray = $outputlangs->get_translations_for_substitutions();
|
||||
foreach ($tmparray as $key => $value) {
|
||||
try {
|
||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||
} catch (OdfException $e) {
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
}
|
||||
|
||||
// Call the beforeODTSave hook
|
||||
|
||||
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
|
||||
$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
// Write new file
|
||||
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||
try {
|
||||
$odfHandler->exportAsAttachedPDF($file);
|
||||
} catch (Exception $e) {
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$odfHandler->saveToDisk($file);
|
||||
} catch (Exception $e) {
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
|
||||
$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
if (!empty($conf->global->MAIN_UMASK)) {
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
|
||||
$odfHandler = null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
} else {
|
||||
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
1375
htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php
Normal file
1375
htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php
Normal file
File diff suppressed because it is too large
Load Diff
147
htdocs/core/modules/asset/mod_asset_advanced.php
Normal file
147
htdocs/core/modules/asset/mod_asset_advanced.php
Normal file
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/asset/mod_asset_advanced.php
|
||||
* \ingroup asset
|
||||
* \brief File containing class for advanced numbering model of Asset
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/asset/modules_asset.php';
|
||||
|
||||
/**
|
||||
* Class to manage customer Bom numbering rules advanced
|
||||
*/
|
||||
class mod_asset_advanced extends ModeleNumRefAsset
|
||||
{
|
||||
/**
|
||||
* Dolibarr version of the loaded document
|
||||
* @var string
|
||||
*/
|
||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
|
||||
/**
|
||||
* @var string Error message
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string name
|
||||
*/
|
||||
public $name = 'advanced';
|
||||
|
||||
|
||||
/**
|
||||
* Returns the description of the numbering model
|
||||
*
|
||||
* @return string Texte descripif
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
global $conf, $langs, $db;
|
||||
|
||||
$langs->load("bills");
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
|
||||
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$texte .= '<input type="hidden" name="action" value="updateMask">';
|
||||
$texte .= '<input type="hidden" name="maskconstBom" value="ASSET_ASSET_ADVANCED_MASK">';
|
||||
$texte .= '<table class="nobordernopadding" width="100%">';
|
||||
|
||||
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Asset"), $langs->transnoentities("Asset"));
|
||||
$tooltip .= $langs->trans("GenericMaskCodes2");
|
||||
$tooltip .= $langs->trans("GenericMaskCodes3");
|
||||
$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Asset"), $langs->transnoentities("Asset"));
|
||||
$tooltip .= $langs->trans("GenericMaskCodes5");
|
||||
|
||||
// Parametrage du prefix
|
||||
$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
|
||||
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskAsset" value="'.$conf->global->ASSET_ASSET_ADVANCED_MASK.'">', $tooltip, 1, 1).'</td>';
|
||||
|
||||
$texte .= '<td class="left" rowspan="2"> <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></td>';
|
||||
|
||||
$texte .= '</tr>';
|
||||
|
||||
$texte .= '</table>';
|
||||
$texte .= '</form>';
|
||||
|
||||
return $texte;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an example of numbering
|
||||
*
|
||||
* @return string Example
|
||||
*/
|
||||
public function getExample()
|
||||
{
|
||||
global $conf, $db, $langs, $mysoc;
|
||||
|
||||
$object = new Asset($db);
|
||||
$object->initAsSpecimen();
|
||||
|
||||
/*$old_code_client = $mysoc->code_client;
|
||||
$old_code_type = $mysoc->typent_code;
|
||||
$mysoc->code_client = 'CCCCCCCCCC';
|
||||
$mysoc->typent_code = 'TTTTTTTTTT';*/
|
||||
|
||||
$numExample = $this->getNextValue($object);
|
||||
|
||||
/*$mysoc->code_client = $old_code_client;
|
||||
$mysoc->typent_code = $old_code_type;*/
|
||||
|
||||
if (!$numExample) {
|
||||
$numExample = $langs->trans('NotConfigured');
|
||||
}
|
||||
return $numExample;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return next free value
|
||||
*
|
||||
* @param Object $object Object we need next value for
|
||||
* @return string Value if KO, <0 if KO
|
||||
*/
|
||||
public function getNextValue($object)
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
// We get cursor rule
|
||||
$mask = $conf->global->ASSET_ASSET_ADVANCED_MASK;
|
||||
|
||||
if (!$mask) {
|
||||
$this->error = 'NotConfigured';
|
||||
return 0;
|
||||
}
|
||||
|
||||
$date = $object->date;
|
||||
|
||||
$numFinal = get_next_value($db, $mask, 'asset_asset', 'ref', '', null, $date);
|
||||
|
||||
return $numFinal;
|
||||
}
|
||||
}
|
||||
161
htdocs/core/modules/asset/mod_asset_standard.php
Normal file
161
htdocs/core/modules/asset/mod_asset_standard.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/asset/mod_asset_standard.php
|
||||
* \ingroup asset
|
||||
* \brief File of class to manage Asset numbering rules standard
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/asset/modules_asset.php';
|
||||
|
||||
/**
|
||||
* Class to manage customer order numbering rules standard
|
||||
*/
|
||||
class mod_asset_standard extends ModeleNumRefAsset
|
||||
{
|
||||
/**
|
||||
* Dolibarr version of the loaded document
|
||||
* @var string
|
||||
*/
|
||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
|
||||
public $prefix = 'ASSET';
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string name
|
||||
*/
|
||||
public $name = 'standard';
|
||||
|
||||
|
||||
/**
|
||||
* Return description of numbering module
|
||||
*
|
||||
* @return string Text with description
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
global $langs;
|
||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an example of numbering
|
||||
*
|
||||
* @return string Example
|
||||
*/
|
||||
public function getExample()
|
||||
{
|
||||
return $this->prefix."0501-0001";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the numbers already in the database do not
|
||||
* cause conflicts that would prevent this numbering working.
|
||||
*
|
||||
* @param Object $object Object we need next value for
|
||||
* @return boolean false if conflict, true if ok
|
||||
*/
|
||||
public function canBeActivated($object)
|
||||
{
|
||||
global $conf, $langs, $db;
|
||||
|
||||
$coyymm = ''; $max = '';
|
||||
|
||||
$posindice = strlen($this->prefix) + 6;
|
||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."asset_asset";
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||
if ($object->ismultientitymanaged == 1) {
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
} elseif ($object->ismultientitymanaged == 2) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$row = $db->fetch_row($resql);
|
||||
if ($row) {
|
||||
$coyymm = substr($row[0], 0, 6); $max = $row[0];
|
||||
}
|
||||
}
|
||||
if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans('ErrorNumRefModel', $max);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return next free value
|
||||
*
|
||||
* @param Object $object Object we need next value for
|
||||
* @return string Value if KO, <0 if KO
|
||||
*/
|
||||
public function getNextValue($object)
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
// first we get the max value
|
||||
$posindice = strlen($this->prefix) + 6;
|
||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."asset_asset";
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||
if ($object->ismultientitymanaged == 1) {
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
} elseif ($object->ismultientitymanaged == 2) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) {
|
||||
$max = intval($obj->max);
|
||||
} else {
|
||||
$max = 0;
|
||||
}
|
||||
} else {
|
||||
dol_syslog("mod_asset_standard::getNextValue", LOG_DEBUG);
|
||||
return -1;
|
||||
}
|
||||
|
||||
//$date=time();
|
||||
$date = $object->date_creation;
|
||||
$yymm = strftime("%y%m", $date);
|
||||
|
||||
if ($max >= (pow(10, 4) - 1)) {
|
||||
$num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
|
||||
} else {
|
||||
$num = sprintf("%04s", $max + 1);
|
||||
}
|
||||
|
||||
dol_syslog("mod_asset_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||
return $this->prefix.$yymm."-".$num;
|
||||
}
|
||||
}
|
||||
158
htdocs/core/modules/asset/modules_asset.php
Normal file
158
htdocs/core/modules/asset/modules_asset.php
Normal file
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/asset/modules_asset.php
|
||||
* \ingroup asset
|
||||
* \brief File that contains parent class for assets document models and parent class for assets numbering models
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
|
||||
|
||||
|
||||
/**
|
||||
* Parent class for documents models
|
||||
*/
|
||||
abstract class ModelePDFAsset extends CommonDocGenerator
|
||||
{
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return list of active generation modules
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param integer $maxfilenamelength Max length of value to show
|
||||
* @return array List of templates
|
||||
*/
|
||||
public static function liste_modeles($db, $maxfilenamelength = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf;
|
||||
|
||||
$type = 'asset';
|
||||
$list = array();
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
$list = getListOfModels($db, $type, $maxfilenamelength);
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parent class to manage numbering of Asset
|
||||
*/
|
||||
abstract class ModeleNumRefAsset
|
||||
{
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* Return if a module can be used or not
|
||||
*
|
||||
* @return boolean true if module can be used
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default description of the numbering template
|
||||
*
|
||||
* @return string Texte descripif
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("asset@asset");
|
||||
return $langs->trans("NoDescription");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an example of numbering
|
||||
*
|
||||
* @return string Example
|
||||
*/
|
||||
public function getExample()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("asset@asset");
|
||||
return $langs->trans("NoExample");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the numbers already in the database do not
|
||||
* cause conflicts that would prevent this numbering working.
|
||||
*
|
||||
* @param Object $object Object we need next value for
|
||||
* @return boolean false if conflict, true if ok
|
||||
*/
|
||||
public function canBeActivated($object)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns next assigned value
|
||||
*
|
||||
* @param Object $object Object we need next value for
|
||||
* @return string Valeur
|
||||
*/
|
||||
public function getNextValue($object)
|
||||
{
|
||||
global $langs;
|
||||
return $langs->trans("NotAvailable");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns version of numbering module
|
||||
*
|
||||
* @return string Valeur
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("admin");
|
||||
|
||||
if ($this->version == 'development') {
|
||||
return $langs->trans("VersionDevelopment");
|
||||
}
|
||||
if ($this->version == 'experimental') {
|
||||
return $langs->trans("VersionExperimental");
|
||||
}
|
||||
if ($this->version == 'dolibarr') {
|
||||
return DOL_VERSION;
|
||||
}
|
||||
if ($this->version) {
|
||||
return $this->version;
|
||||
}
|
||||
return $langs->trans("NotAvailable");
|
||||
}
|
||||
}
|
||||
@ -58,9 +58,9 @@ class modAsset extends DolibarrModules
|
||||
// Module label (no space allowed), used if translation string 'ModuleAssetsName' not found (MyModue is name of module).
|
||||
$this->name = preg_replace('/^mod/i', '', get_class($this));
|
||||
// Module description, used if translation string 'ModuleAssetsDesc' not found (MyModue is name of module).
|
||||
$this->description = "Assets module";
|
||||
$this->description = "Asset module";
|
||||
// Used only if file README.md and README-LL.md not found.
|
||||
$this->descriptionlong = "Assets module to manage assets module and depreciation charge on Dolibarr";
|
||||
$this->descriptionlong = "Asset module to manage assets module and depreciation charge on Dolibarr";
|
||||
|
||||
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
|
||||
$this->version = 'development';
|
||||
@ -103,6 +103,15 @@ class modAsset extends DolibarrModules
|
||||
// 1=>array('ASSETS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
|
||||
// );
|
||||
$this->const = array();
|
||||
$this->const[1] = array(
|
||||
"ASSET_DEPRECIATION_DURATION_PER_YEAR",
|
||||
"chaine",
|
||||
"365",
|
||||
"Duration per year to calculate depreciation. In some case, can be 360 days",
|
||||
0,
|
||||
'current',
|
||||
1
|
||||
);
|
||||
|
||||
|
||||
if (!isset($conf->asset) || !isset($conf->asset->enabled)) {
|
||||
@ -192,13 +201,29 @@ class modAsset extends DolibarrModules
|
||||
$this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
|
||||
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 51004; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'Read asset models'; // Permission label
|
||||
$this->rights[$r][2] = 'r';
|
||||
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'model_advance'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
|
||||
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 51005; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'Setup types of asset'; // Permission label
|
||||
$this->rights[$r][1] = 'Create/Update asset models'; // Permission label
|
||||
$this->rights[$r][2] = 'w';
|
||||
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'setup_advance'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
|
||||
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
|
||||
$this->rights[$r][4] = 'model_advance'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
|
||||
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 51006; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'Delete asset models'; // Permission label
|
||||
$this->rights[$r][2] = 'd';
|
||||
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'model_advance'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
|
||||
$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2)
|
||||
|
||||
// Menus
|
||||
//-------
|
||||
|
||||
@ -546,31 +546,30 @@ class pdf_cornas extends ModelePDFSuppliersOrders
|
||||
$posYAfterDescription = 0;
|
||||
|
||||
// We start with Photo of product line
|
||||
if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
|
||||
$pdf->AddPage('', '', true);
|
||||
if (!empty($tplidx)) {
|
||||
$pdf->useTemplate($tplidx);
|
||||
}
|
||||
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
|
||||
$this->_pagehead($pdf, $object, 0, $outputlangs);
|
||||
}
|
||||
$pdf->setPage($pageposbefore + 1);
|
||||
if ($this->getColumnStatus('photo')) {
|
||||
// We start with Photo of product line
|
||||
if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
|
||||
$pdf->AddPage('', '', true);
|
||||
if (!empty($tplidx)) {
|
||||
$pdf->useTemplate($tplidx);
|
||||
}
|
||||
$pdf->setPage($pageposbefore + 1);
|
||||
|
||||
$curY = $tab_top_newpage;
|
||||
$curY = $tab_top_newpage;
|
||||
|
||||
// Allows data in the first page if description is long enough to break in multiples pages
|
||||
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
|
||||
$showpricebeforepagebreak = 1;
|
||||
} else {
|
||||
$showpricebeforepagebreak = 0;
|
||||
// Allows data in the first page if description is long enough to break in multiples pages
|
||||
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
|
||||
$showpricebeforepagebreak = 1;
|
||||
} else {
|
||||
$showpricebeforepagebreak = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) {
|
||||
$curX = $this->posxpicture - 1;
|
||||
$pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
|
||||
// $pdf->Image does not increase value return by getY, so we save it manually
|
||||
$posYAfterImage = $curY + $imglinesize['height'];
|
||||
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
|
||||
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
|
||||
// $pdf->Image does not increase value return by getY, so we save it manually
|
||||
$posYAfterImage = $curY + $imglinesize['height'];
|
||||
}
|
||||
}
|
||||
// Description of product line
|
||||
$curX = $this->posxdesc - 1;
|
||||
|
||||
@ -18,15 +18,14 @@ if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table
|
||||
if (empty($extrafieldsobjectprefix)) {
|
||||
$extrafieldsobjectprefix = 'ef.';
|
||||
}
|
||||
|
||||
foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) {
|
||||
if (!empty($extrafields->attributes[$extrafieldsobjectkey]['list'][$key])) {
|
||||
$arrayfields[$extrafieldsobjectprefix.$key] = array(
|
||||
'label' => $extrafields->attributes[$extrafieldsobjectkey]['label'][$key],
|
||||
'type' => $extrafields->attributes[$extrafieldsobjectkey]['type'][$key],
|
||||
'checked' => (($extrafields->attributes[$extrafieldsobjectkey]['list'][$key] < 0) ? 0 : 1),
|
||||
'checked' => ((dol_eval($extrafields->attributes[$extrafieldsobjectkey]['list'][$key], 1) <= 0) ? 0 : 1),
|
||||
'position' => $extrafields->attributes[$extrafieldsobjectkey]['pos'][$key],
|
||||
'enabled' => (abs((int) $extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && $extrafields->attributes[$extrafieldsobjectkey]['perms'][$key]),
|
||||
'enabled' => (abs((int) $extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && dol_eval($extrafields->attributes[$extrafieldsobjectkey]['perms'][$key], 1)),
|
||||
'langfile' => $extrafields->attributes[$extrafieldsobjectkey]['langfile'][$key],
|
||||
'help' => $extrafields->attributes[$extrafieldsobjectkey]['help'][$key],
|
||||
);
|
||||
|
||||
@ -107,19 +107,7 @@ if (empty($reshook) && isset($extrafields->attributes[$object->table_element]['l
|
||||
|
||||
// Print line tr of extra field
|
||||
if ($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra] == 'separate') {
|
||||
$extrafields_collapse_num = '';
|
||||
$extrafield_param = $extrafields->attributes[$object->table_element]['param'][$tmpkeyextra];
|
||||
if (!empty($extrafield_param) && is_array($extrafield_param)) {
|
||||
$extrafield_param_list = array_keys($extrafield_param['options']);
|
||||
|
||||
if (count($extrafield_param_list) > 0) {
|
||||
$extrafield_collapse_display_value = intval($extrafield_param_list[0]);
|
||||
|
||||
if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) {
|
||||
$extrafields_collapse_num = $extrafields->attributes[$object->table_element]['pos'][$tmpkeyextra];
|
||||
}
|
||||
}
|
||||
}
|
||||
$extrafields_collapse_num = $tmpkeyextra;
|
||||
|
||||
print $extrafields->showSeparator($tmpkeyextra, $object);
|
||||
|
||||
|
||||
@ -6,9 +6,10 @@
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2022 OpenDSI <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -68,6 +69,9 @@ if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf-
|
||||
if (in_array($object->element, array('propal', 'commande', 'order', 'facture', 'facturerec', 'invoice', 'supplier_proposal', 'order_supplier', 'invoice_supplier', 'invoice_supplier_rec'))) {
|
||||
$colspan++; // With this, there is a column move button
|
||||
}
|
||||
if (!empty($conf->asset->enabled) && $object->element == 'invoice_supplier') {
|
||||
$colspan++;
|
||||
}
|
||||
|
||||
//print $object->element;
|
||||
// Lines for extrafield
|
||||
@ -356,7 +360,7 @@ if ($nolinesbefore) {
|
||||
}
|
||||
if (is_object($objectline)) {
|
||||
$temps = $objectline->showOptionals($extrafields, 'create', array(), '', '', 1, 'line');
|
||||
;
|
||||
|
||||
if (!empty($temps)) {
|
||||
print '<div style="padding-top: 10px" id="extrafield_lines_area_create" name="extrafield_lines_area_create">';
|
||||
print $temps;
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2022 OpenDSI <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -72,6 +73,11 @@ if (in_array($object->element, array('propal', 'supplier_proposal', 'facture', '
|
||||
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
|
||||
$colspan += 2;
|
||||
}
|
||||
if (!empty($conf->asset->enabled) && $object->element == 'invoice_supplier') {
|
||||
$colspan++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
print "<!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php -->\n";
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2022 OpenDSI <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -140,6 +141,10 @@ if ($outputalsopricetotalwithtax) {
|
||||
print '<td class="right" style="width: 80px">'.$langs->trans('TotalTTCShort').'</td>';
|
||||
}
|
||||
|
||||
if (!empty($conf->asset->enabled) && $object->element == 'invoice_supplier') {
|
||||
print '<td class="linecolasset"></td>';
|
||||
}
|
||||
|
||||
print '<td class="linecoledit"></td>'; // No width to allow autodim
|
||||
|
||||
print '<td class="linecoldelete" style="width: 10px"></td>';
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2022 OpenDSI <support@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -387,6 +388,35 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($conf->asset->enabled) && $object->element == 'invoice_supplier') {
|
||||
print '<td class="linecolasset center">';
|
||||
$coldisplay++;
|
||||
if (!empty($product_static->accountancy_code_buy) ||
|
||||
!empty($product_static->accountancy_code_buy_intra) ||
|
||||
!empty($product_static->accountancy_code_buy_export)
|
||||
) {
|
||||
$accountancy_category_asset = $conf->global->ASSET_ACCOUNTANCY_CATEGORY;
|
||||
$filters = array();
|
||||
if (!empty($product_static->accountancy_code_buy)) $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy) . "'";
|
||||
if (!empty($product_static->accountancy_code_buy_intra)) $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_intra) . "'";
|
||||
if (!empty($product_static->accountancy_code_buy_export)) $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_export) . "'";
|
||||
$sql = "SELECT COUNT(*) AS found";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account";
|
||||
$sql .= " WHERE pcg_type = '" . $this->db->escape($conf->global->ASSET_ACCOUNTANCY_CATEGORY) . "'";
|
||||
$sql .= " AND (" . implode(' OR ', $filters). ")";
|
||||
$resql_asset = $this->db->query($sql);
|
||||
if (!$resql_asset) {
|
||||
print 'Error SQL: ' . $this->db->lasterror();
|
||||
} elseif ($obj = $this->db->fetch_object($resql_asset)) {
|
||||
if (!empty($obj->found)) {
|
||||
print '<a class="reposition" href="' . DOL_URL_ROOT . '/asset/card.php?action=create&supplier_invoice_id=' . $object->id . '&token=' . newToken() . '">';
|
||||
print img_edit_add() . '</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print '<td class="linecoledit center">';
|
||||
$coldisplay++;
|
||||
if (($line->info_bits & 2) == 2 || !empty($disableedit)) {
|
||||
|
||||
@ -116,7 +116,7 @@ $fieldstosearchall = array(
|
||||
'e.ref'=>"Ref",
|
||||
's.nom'=>"ThirdParty",
|
||||
'e.note_public'=>'NotePublic',
|
||||
'e.shipping_method_id'=>'SendingMethod',
|
||||
//'e.fk_shipping_method'=>'SendingMethod', // TODO fix this, does not work
|
||||
'e.tracking_number'=>"TrackingNumber",
|
||||
);
|
||||
if (empty($user->socid)) {
|
||||
@ -134,7 +134,7 @@ $arrayfields = array(
|
||||
'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0, 'position'=>7),
|
||||
'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers, 'position'=>8),
|
||||
'e.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1, 'position'=>9),
|
||||
'e.shipping_method_id'=>array('label'=>$langs->trans('SendingMethod'), 'checked'=>1, 'position'=>10),
|
||||
'e.fk_shipping_method'=>array('label'=>$langs->trans('SendingMethod'), 'checked'=>1, 'position'=>10),
|
||||
'e.tracking_number'=>array('label'=>$langs->trans("TrackingNumber"), 'checked'=>1, 'position'=>11),
|
||||
'e.weight'=>array('label'=>$langs->trans("Weight"), 'checked'=>0, 'position'=>12),
|
||||
'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
|
||||
@ -654,7 +654,7 @@ if (!empty($arrayfields['e.date_delivery']['checked'])) {
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['e.shipping_method_id']['checked'])) {
|
||||
if (!empty($arrayfields['e.fk_shipping_method']['checked'])) {
|
||||
// Delivery method
|
||||
print '<td class="liste_titre center">';
|
||||
$shipment->fetch_delivery_methods();
|
||||
@ -751,8 +751,8 @@ if (!empty($arrayfields['e.weight']['checked'])) {
|
||||
if (!empty($arrayfields['e.date_delivery']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['e.shipping_method_id']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.shipping_method_id']['label'], $_SERVER["PHP_SELF"], "e.fk_shipping_method", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['e.fk_shipping_method']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "e.fk_shipping_method", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['e.tracking_number']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.tracking_number']['label'], $_SERVER["PHP_SELF"], "e.tracking_number", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
@ -901,7 +901,7 @@ while ($i < min($num, $limit)) {
|
||||
print dol_print_date($db->jdate($obj->delivery_date), "dayhour");
|
||||
print "</td>\n";
|
||||
}
|
||||
if (!empty($arrayfields['e.shipping_method_id']['checked'])) {
|
||||
if (!empty($arrayfields['e.fk_shipping_method']['checked'])) {
|
||||
// Get code using getLabelFromKey
|
||||
$code=$langs->getLabelFromKey($db, $shipment->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
|
||||
print '<td class="center">';
|
||||
|
||||
@ -1342,6 +1342,23 @@ if ($action == 'create') {
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
print dol_htmlentitiesbr($objp->description);
|
||||
|
||||
$objectline = new FichinterLigne($db);
|
||||
$objectline->fetch($objp->rowid);
|
||||
$objectline->fetch_optionals();
|
||||
|
||||
$extrafields->fetch_name_optionals_label($objectline->table_element);
|
||||
|
||||
if (!empty($extrafields)) {
|
||||
$temps = $objectline->showOptionals($extrafields, 'view', array(), '', '', 1, 'line');
|
||||
if (!empty($temps)) {
|
||||
print '<div style="padding-top: 10px" id="extrafield_lines_area_'.$line->id.'" name="extrafield_lines_area_'.$line->id.'">';
|
||||
print $temps;
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
|
||||
// Date
|
||||
print '<td class="center" width="150">'.(empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR) ?dol_print_date($db->jdate($objp->date_intervention), 'dayhour') : dol_print_date($db->jdate($objp->date_intervention), 'day')).'</td>';
|
||||
|
||||
@ -1378,15 +1395,6 @@ if ($action == 'create') {
|
||||
}
|
||||
|
||||
print '</tr>';
|
||||
|
||||
$line = new FichinterLigne($db);
|
||||
$line->fetch($objp->rowid);
|
||||
|
||||
$extrafields->fetch_name_optionals_label($line->table_element);
|
||||
|
||||
$line->fetch_optionals();
|
||||
|
||||
print $line->showOptionals($extrafields, 'view', array('colspan'=>5));
|
||||
}
|
||||
|
||||
// Line in update mode
|
||||
@ -1405,6 +1413,22 @@ if ($action == 'create') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor = new DolEditor('np_desc', $objp->description, '', 164, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, '90%');
|
||||
$doleditor->Create();
|
||||
|
||||
$objectline = new FichinterLigne($db);
|
||||
$objectline->fetch($objp->rowid);
|
||||
$objectline->fetch_optionals();
|
||||
|
||||
$extrafields->fetch_name_optionals_label($objectline->table_element);
|
||||
|
||||
if (!empty($extrafields)) {
|
||||
$temps = $objectline->showOptionals($extrafields, 'edit', array(), '', '', 1, 'line');
|
||||
if (!empty($temps)) {
|
||||
print '<div style="padding-top: 10px" id="extrafield_lines_area_'.$line->id.'" name="extrafield_lines_area_'.$line->id.'">';
|
||||
print $temps;
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
|
||||
// Date d'intervention
|
||||
@ -1431,14 +1455,6 @@ if ($action == 'create') {
|
||||
print '<input type="submit" class="button buttongen marginbottomonly button-save" name="save" value="'.$langs->trans("Save").'">';
|
||||
print '<input type="submit" class="button buttongen marginbottomonly button-cancel" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
$line = new FichinterLigne($db);
|
||||
$line->fetch($objp->rowid);
|
||||
|
||||
$extrafields->fetch_name_optionals_label($line->table_element);
|
||||
$line->fetch_optionals();
|
||||
|
||||
print $line->showOptionals($extrafields, 'edit', array('colspan'=>5));
|
||||
}
|
||||
|
||||
$i++;
|
||||
@ -1481,6 +1497,20 @@ if ($action == 'create') {
|
||||
$doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'restricthtml'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, '90%');
|
||||
$doleditor->Create();
|
||||
}
|
||||
|
||||
$objectline = new FichinterLigne($db);
|
||||
$extrafields->fetch_name_optionals_label($objectline->table_element);
|
||||
|
||||
if (is_object($objectline)) {
|
||||
$temps = $objectline->showOptionals($extrafields, 'create', array(), '', '', 1, 'line');
|
||||
|
||||
if (!empty($temps)) {
|
||||
print '<div style="padding-top: 10px" id="extrafield_lines_area_create" name="extrafield_lines_area_create">';
|
||||
print $temps;
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
|
||||
// Date intervention
|
||||
@ -1513,14 +1543,6 @@ if ($action == 'create') {
|
||||
print '<td class="center" valign="middle" colspan="3"><input type="submit" class="button button-add" value="'.$langs->trans('Add').'" name="addline"></td>';
|
||||
print '</tr>';
|
||||
|
||||
//Line extrafield
|
||||
|
||||
$lineadd = new FichinterLigne($db);
|
||||
|
||||
$extrafields->fetch_name_optionals_label($lineadd->table_element);
|
||||
|
||||
print $lineadd->showOptionals($extrafields, 'edit', array('colspan'=>5));
|
||||
|
||||
if (!$num) {
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
@ -1067,79 +1067,4 @@ class Evaluation extends CommonObject
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $action
|
||||
* @param int $selected
|
||||
*/
|
||||
// public function printObjectLines($action, $selected = 0)
|
||||
// {
|
||||
// global $conf, $hookmanager, $langs, $user, $extrafields, $object;
|
||||
// // TODO We should not use global var for this
|
||||
// global $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $disableremove, $outputalsopricetotalwithtax;
|
||||
//
|
||||
// // Define usemargins
|
||||
//// $usemargins = 0;
|
||||
//// if (!empty($conf->margin->enabled) && !empty($this->element) && in_array($this->element, array('facture', 'facturerec', 'propal', 'commande'))) {
|
||||
//// $usemargins = 1;
|
||||
//// }
|
||||
//
|
||||
// $num = count($this->lines);
|
||||
//
|
||||
// // Line extrafield
|
||||
// if (!is_object($extrafields)) {
|
||||
// require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
// $extrafields = new ExtraFields($this->db);
|
||||
// }
|
||||
// $extrafields->fetch_name_optionals_label($this->table_element_line);
|
||||
//
|
||||
// $parameters = array('num'=>$num, 'selected'=>$selected, 'table_element_line'=>$this->table_element_line);
|
||||
// $reshook = $hookmanager->executeHooks('printObjectLineTitle', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
// if (empty($reshook)) {
|
||||
// // Output template part (modules that overwrite templates must declare this into descriptor)
|
||||
// // Note: This is deprecated. If you need to overwrite the tpl file, use instead the hook.
|
||||
// include dol_buildpath('hrm/core/tpl/objectline_title.tpl.php');
|
||||
// }
|
||||
//
|
||||
// $i = 0;
|
||||
//
|
||||
// print "<!-- begin printObjectLines() --><tbody>\n";
|
||||
// foreach ($this->lines as $line) {
|
||||
// //Line extrafield
|
||||
// $line->fetch_optionals();
|
||||
//
|
||||
// //if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
|
||||
// if (is_object($hookmanager)) { // Old code is commented on preceding line.
|
||||
// if (empty($line->fk_parent_line)) {
|
||||
// $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'selected'=>$selected, 'table_element_line'=>$line->table_element);
|
||||
// $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
// } else {
|
||||
// $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line);
|
||||
// $reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
// }
|
||||
// }
|
||||
// if (empty($reshook)) {
|
||||
// $this->printObjectLine($action, $line);
|
||||
// }
|
||||
//
|
||||
// $i++;
|
||||
// }
|
||||
// print "</tbody><!-- end printObjectLines() -->\n";
|
||||
// }
|
||||
|
||||
// public function printObjectLine($action, $line)
|
||||
// {
|
||||
// global $conf, $langs, $user, $object, $hookmanager;
|
||||
// global $form;
|
||||
// global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this !
|
||||
//
|
||||
// $object_rights = $this->getRights();
|
||||
//
|
||||
// $element = $this->element;
|
||||
//
|
||||
// $text = '';
|
||||
// $description = '';
|
||||
//
|
||||
// include dol_buildpath('hrm/tpl/objectline_view.tpl.php');
|
||||
// }
|
||||
}
|
||||
|
||||
27
htdocs/install/mysql/data/llx_c_partnership_type.sql
Normal file
27
htdocs/install/mysql/data/llx_c_partnership_type.sql
Normal file
@ -0,0 +1,27 @@
|
||||
-- Copyright (C) 2020 florian HENRY florian.henry@scopen.fr
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
--
|
||||
--
|
||||
|
||||
--
|
||||
-- Do not place a comment at the end of the line, this file is parsed when
|
||||
-- from the install and all '--' are removed.
|
||||
--
|
||||
-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors
|
||||
-- de l'install et tous les sigles '--' sont supprimés.
|
||||
--
|
||||
|
||||
INSERT INTO llx_c_partnership_type (code, label, active) VALUES ('DEFAULT', 'Default', 1);
|
||||
|
||||
@ -23,4 +23,4 @@ INSERT INTO llx_c_ticket_type (code, pos, label, active, use_default, descriptio
|
||||
INSERT INTO llx_c_ticket_type (code, pos, label, active, use_default, description) VALUES('PROBLEM', '22', 'Problem', 0, 0, NULL);
|
||||
INSERT INTO llx_c_ticket_type (code, pos, label, active, use_default, description) VALUES('REQUEST', '25', 'Change or enhancement request', 1, 0, NULL);
|
||||
INSERT INTO llx_c_ticket_type (code, pos, label, active, use_default, description) VALUES('PROJECT', '30', 'Project', 0, 0, NULL);
|
||||
INSERT INTO llx_c_ticket_type (code, pos, label, active, use_default, description) VALUES('OTHER', '40', 'Other', 1, 0, NULL);
|
||||
INSERT INTO llx_c_ticket_type (code, pos, label, active, use_default, description) VALUES('OTHER', '40', 'Other', 1, 1, NULL);
|
||||
|
||||
@ -507,6 +507,7 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) value
|
||||
INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_CANCEL','Holiday canceled','Executed when a holiday is canceled','holiday',802);
|
||||
INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_DELETE','Holiday deleted','Executed when a holiday is deleted','holiday',804);
|
||||
|
||||
|
||||
-- We do not delete old mexican legal forms because they may have been used. User will have to insert the new one manually not inserted because of conflict if he need them.
|
||||
--DELETE FROM llx_c_forme_juridique WHERE code IN ('15401', '15402', '15403', '15404', '15405', '15406');
|
||||
|
||||
@ -529,3 +530,7 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154,
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15417', '624 - Coordinados', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15418', '625 - Régimen de las Actividades Empresariales con ingresos a través de Plataformas Tecnológicas', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15419', '626 - Régimen Simplificado de Confianza', 1);
|
||||
|
||||
-- VMYSQL4.3 ALTER TABLE llx_user MODIFY COLUMN fk_soc integer NULL;
|
||||
-- VPGSQL8.2 ALTER TABLE llx_user ALTER COLUMN fk_soc DROP NOT NULL;
|
||||
|
||||
|
||||
@ -69,6 +69,26 @@ ALTER TABLE llx_c_typent MODIFY COLUMN libelle varchar(128);
|
||||
UPDATE llx_rights_def SET perms = 'writeall' WHERE perms = 'writeall_advance' AND module = 'holiday';
|
||||
|
||||
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15401', '601 - General de Ley Personas Morales', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15402', '603 - Personas Morales con Fines no Lucrativos', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15403', '605 - Sueldos y Salarios e Ingresos Asimilados a Salarios', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15404', '606 - Arrendamiento', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15405', '607 - Régimen de Enajenación o Adquisición de Bienes', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15406', '608 - Demás ingresos', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15407', '610 - Residentes en el Extranjero sin Establecimiento Permanente en México', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15408', '611 - Ingresos por Dividendos (socios y accionistas)', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15409', '612 - Personas Físicas con Actividades Empresariales y Profesionales', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15410', '614 - Ingresos por intereses', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15411', '615 - Régimen de los ingresos por obtención de premios', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15412', '616 - Sin obligaciones fiscales', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15413', '620 - Sociedades Cooperativas de Producción que optan por diferir sus ingresos', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15414', '621 - Incorporación Fiscal', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15415', '622 - Actividades Agrícolas, Ganaderas, Silvícolas y Pesqueras', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15416', '623 - Opcional para Grupos de Sociedades', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15417', '624 - Coordinados', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15418', '625 - Régimen de las Actividades Empresariales con ingresos a través de Plataformas Tecnológicas', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15419', '626 - Régimen Simplificado de Confianza', 1);
|
||||
|
||||
|
||||
-- v16
|
||||
|
||||
@ -251,3 +271,5 @@ ALTER TABLE llx_reception MODIFY COLUMN ref_supplier varchar(128);
|
||||
|
||||
ALTER TABLE llx_bank_account ADD COLUMN pti_in_ctti smallint DEFAULT 0 AFTER domiciliation;
|
||||
|
||||
-- Set default ticket type to OTHER if no default exists
|
||||
UPDATE llx_c_ticket_type SET use_default=1 WHERE code='OTHER' AND NOT EXISTS(SELECT * FROM (SELECT * FROM llx_c_ticket_type) AS t WHERE use_default=1);
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_login (login, entity);
|
||||
|
||||
ALTER TABLE llx_user ADD INDEX idx_user_fk_societe (fk_soc);
|
||||
ALTER TABLE llx_user ADD INDEX idx_user_fk_societe (fk_soc);
|
||||
|
||||
ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_socpeople (fk_socpeople);
|
||||
ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_member (fk_member);
|
||||
|
||||
@ -64,12 +64,12 @@ create table llx_user
|
||||
--module_comm smallint DEFAULT 1,
|
||||
--module_compta smallint DEFAULT 1,
|
||||
|
||||
fk_soc integer, -- id thirdparty if user linked to a company (external user)
|
||||
fk_socpeople integer, -- id contact origin if user linked to a contact
|
||||
fk_member integer, -- if member if suer linked to a member
|
||||
fk_user integer, -- Supervisor, hierarchic parent
|
||||
fk_user_expense_validator integer,
|
||||
fk_user_holiday_validator integer,
|
||||
fk_soc integer NULL, -- id thirdparty if user linked to a company (external user)
|
||||
fk_socpeople integer NULL, -- id contact origin if user linked to a contact
|
||||
fk_member integer NULL, -- if member if suer linked to a member
|
||||
fk_user integer NULL, -- Supervisor, hierarchic parent
|
||||
fk_user_expense_validator integer NULL,
|
||||
fk_user_holiday_validator integer NULL,
|
||||
|
||||
idpers1 varchar(128),
|
||||
idpers2 varchar(128),
|
||||
|
||||
@ -1070,6 +1070,7 @@ DictionaryExpenseTaxCat=Expense report - Transportation categories
|
||||
DictionaryExpenseTaxRange=Expense report - Range by transportation category
|
||||
DictionaryTransportMode=Intracomm report - Transport mode
|
||||
DictionaryBatchStatus=Product lot/serial Quality Control status
|
||||
DictionaryAssetDisposalType=Type of disposal of assets
|
||||
TypeOfUnit=Type of unit
|
||||
SetupSaved=Setup saved
|
||||
SetupNotSaved=Setup not saved
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
# Copyright (C) 2018-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -16,52 +16,171 @@
|
||||
#
|
||||
# Generic
|
||||
#
|
||||
Assets = Assets
|
||||
NewAsset = New asset
|
||||
AccountancyCodeAsset = Accounting code (asset)
|
||||
AccountancyCodeDepreciationAsset = Accounting code (depreciation asset account)
|
||||
AccountancyCodeDepreciationExpense = Accounting code (depreciation expense account)
|
||||
NewAssetType=New asset type
|
||||
AssetsTypeSetup=Asset type setup
|
||||
AssetTypeModified=Asset type modified
|
||||
AssetType=Asset type
|
||||
NewAsset=New asset
|
||||
AccountancyCodeAsset=Accounting code (asset)
|
||||
AccountancyCodeDepreciationAsset=Accounting code (depreciation asset account)
|
||||
AccountancyCodeDepreciationExpense=Accounting code (depreciation expense account)
|
||||
AssetsLines=Assets
|
||||
DeleteType=Delete
|
||||
DeleteAnAssetType=Delete an asset type
|
||||
ConfirmDeleteAssetType=Are you sure you want to delete this asset type?
|
||||
ShowTypeCard=Show type '%s'
|
||||
DeleteAnAssetType=Delete an asset model
|
||||
ConfirmDeleteAssetType=Are you sure you want to delete this asset model?
|
||||
ShowTypeCard=Show model '%s'
|
||||
|
||||
# Module label 'ModuleAssetsName'
|
||||
ModuleAssetsName = Assets
|
||||
ModuleAssetsName=Assets
|
||||
# Module description 'ModuleAssetsDesc'
|
||||
ModuleAssetsDesc = Assets description
|
||||
ModuleAssetsDesc=Assets description
|
||||
|
||||
#
|
||||
# Admin page
|
||||
#
|
||||
AssetsSetup = Assets setup
|
||||
Settings = Settings
|
||||
AssetsSetupPage = Assets setup page
|
||||
ExtraFieldsAssetsType = Complementary attributes (Asset type)
|
||||
AssetsType=Asset type
|
||||
AssetsTypeId=Asset type id
|
||||
AssetsTypeLabel=Asset type label
|
||||
AssetsTypes=Assets types
|
||||
AssetSetup=Assets setup
|
||||
AssetSetupPage=Assets setup page
|
||||
ExtraFieldsAssetModel=Complementary attributes (Asset's model)
|
||||
|
||||
AssetsType=Asset model
|
||||
AssetsTypeId=Asset model id
|
||||
AssetsTypeLabel=Asset model label
|
||||
AssetsTypes=Assets models
|
||||
ASSET_ACCOUNTANCY_CATEGORY=Fixed asset accounting group
|
||||
|
||||
#
|
||||
# Menu
|
||||
#
|
||||
MenuAssets = Assets
|
||||
MenuNewAsset = New asset
|
||||
MenuTypeAssets = Type assets
|
||||
MenuListAssets = List
|
||||
MenuNewTypeAssets = New
|
||||
MenuListTypeAssets = List
|
||||
MenuAssets=Assets
|
||||
MenuNewAsset=New asset
|
||||
MenuAssetModels=Model assets
|
||||
MenuListAssets=List
|
||||
MenuNewAssetModel=New asset's model
|
||||
MenuListAssetModels=List
|
||||
|
||||
#
|
||||
# Module
|
||||
#
|
||||
ConfirmDeleteAsset=Do you really want to remove this asset?
|
||||
|
||||
#
|
||||
# Tab
|
||||
#
|
||||
AssetDepreciationOptions=Depreciation options
|
||||
AssetAccountancyCodes=Accounting accounts
|
||||
AssetDepreciation=Depreciation
|
||||
|
||||
#
|
||||
# Asset
|
||||
#
|
||||
Asset=Asset
|
||||
NewAssetType=New asset type
|
||||
NewAsset=New asset
|
||||
ConfirmDeleteAsset=Are you sure you want to delete this asset ?
|
||||
Assets=Assets
|
||||
AssetReversalAmountHT=Reversal amount (without taxes)
|
||||
AssetAcquisitionValueHT=Acquisition amount (without taxes)
|
||||
AssetRecoveredVAT=Recovered VAT
|
||||
AssetReversalDate=Reversal date
|
||||
AssetDateAcquisition=Acquisition date
|
||||
AssetDateStart=Date of start-up
|
||||
AssetAcquisitionType=Type of acquisition
|
||||
AssetAcquisitionTypeNew=New
|
||||
AssetAcquisitionTypeOccasion=Used
|
||||
AssetType=Type of asset
|
||||
AssetTypeIntangible=Intangible
|
||||
AssetTypeTangible=Tangible
|
||||
AssetTypeInProgress=In progress
|
||||
AssetTypeFinancial=Financial
|
||||
AssetNotDepreciated=Not depreciated
|
||||
AssetDisposal=Disposal
|
||||
AssetConfirmDisposalAsk=Are you sure you want to dispose of the asset <b> %s</b>?
|
||||
AssetConfirmReOpenAsk=Are you sure you want to reopen the asset <b> %s</b>?
|
||||
|
||||
#
|
||||
# Asset status
|
||||
#
|
||||
AssetInProgress=In progress
|
||||
AssetDisposed=Disposed
|
||||
AssetRecorded=Accounted
|
||||
|
||||
#
|
||||
# Asset disposal
|
||||
#
|
||||
AssetDisposalDate=Date of disposal
|
||||
AssetDisposalAmount=Disposal value
|
||||
AssetDisposalType=Type of disposal
|
||||
AssetDisposalDepreciated=Depreciate the year of transfer
|
||||
AssetDisposalSubjectToVat=Disposal subject to VAT
|
||||
|
||||
#
|
||||
# Asset model
|
||||
#
|
||||
AssetModel=Asset's model
|
||||
AssetModels=Asset's models
|
||||
|
||||
#
|
||||
# Asset depreciation options
|
||||
#
|
||||
AssetDepreciationOptionEconomic=Economic depreciation
|
||||
AssetDepreciationOptionAcceleratedDepreciation=Accelerated depreciation (tax)
|
||||
AssetDepreciationOptionDepreciationType=Depreciation type
|
||||
AssetDepreciationOptionDepreciationTypeLinear=Linear
|
||||
AssetDepreciationOptionDepreciationTypeDegressive=Degressive
|
||||
AssetDepreciationOptionDepreciationTypeExceptional=Exceptional
|
||||
AssetDepreciationOptionDegressiveRate=Degressive rate
|
||||
AssetDepreciationOptionAcceleratedDepreciation=Accelerated (tax)
|
||||
AssetDepreciationOptionDuration=Duration
|
||||
AssetDepreciationOptionDurationType=Type duration
|
||||
AssetDepreciationOptionDurationTypeAnnual=Annual
|
||||
AssetDepreciationOptionDurationTypeMonthly=Monthly
|
||||
AssetDepreciationOptionDurationTypeDaily=Daily
|
||||
AssetDepreciationOptionRate=Rate (%%)
|
||||
AssetDepreciationOptionAmountBaseDepreciationHT=Depreciation base (excl. VAT)
|
||||
AssetDepreciationOptionAmountBaseDeductibleHT=Deductible base (excl. VAT)
|
||||
AssetDepreciationOptionTotalAmountLastDepreciationHT=Total amount last depreciation (excl. VAT)
|
||||
|
||||
#
|
||||
# Asset accountancy codes
|
||||
#
|
||||
AssetAccountancyCodeDepreciationEconomic=Economic depreciation
|
||||
AssetAccountancyCodeAsset=Asset
|
||||
AssetAccountancyCodeDepreciationAsset=Depreciation
|
||||
AssetAccountancyCodeDepreciationExpense=Depreciation expense
|
||||
AssetAccountancyCodeValueAssetSold=Value of asset disposed
|
||||
AssetAccountancyCodeReceivableOnAssignment=Receivable on disposal
|
||||
AssetAccountancyCodeProceedsFromSales=Proceeds from disposal
|
||||
AssetAccountancyCodeVatCollected=Collected VAT
|
||||
AssetAccountancyCodeVatDeductible=Recovered VAT on assets
|
||||
AssetAccountancyCodeDepreciationAcceleratedDepreciation=Accelerated depreciation (tax)
|
||||
AssetAccountancyCodeAcceleratedDepreciation=Account
|
||||
AssetAccountancyCodeEndowmentAcceleratedDepreciation=Depreciation expense
|
||||
AssetAccountancyCodeProvisionAcceleratedDepreciation=Repossession/Provision
|
||||
|
||||
#
|
||||
# Asset depreciation
|
||||
#
|
||||
AssetBaseDepreciationHT=Depreciation basis (excl. VAT)
|
||||
AssetDepreciationBeginDate=Start of depreciation on
|
||||
AssetDepreciationDuration=Duration
|
||||
AssetDepreciationRate=Rate (%%)
|
||||
AssetDepreciationDate=Depreciation date
|
||||
AssetDepreciationHT=Depreciation (excl. VAT)
|
||||
AssetCumulativeDepreciationHT=Cumulative depreciation (excl. VAT)
|
||||
AssetResidualHT=Residual value (excl. VAT)
|
||||
AssetDispatchedInBookkeeping=Depreciation recorded
|
||||
AssetFutureDepreciationLine=Future depreciation
|
||||
AssetDepreciationReversal=Reversal
|
||||
|
||||
#
|
||||
# Errors
|
||||
#
|
||||
AssetErrorAssetOrAssetModelIDNotProvide=Id of the asset or the model sound has not been provided
|
||||
AssetErrorFetchAccountancyCodesForMode=Error when retrieving the accounting accounts for the '%s' depreciation mode
|
||||
AssetErrorDeleteAccountancyCodesForMode=Error when deleting accounting accounts from the '%s' depreciation mode
|
||||
AssetErrorInsertAccountancyCodesForMode=Error when inserting the accounting accounts of the depreciation mode '%s'
|
||||
AssetErrorFetchDepreciationOptionsForMode=Error when retrieving options for the '%s' depreciation mode
|
||||
AssetErrorDeleteDepreciationOptionsForMode=Error when deleting the '%s' depreciation mode options
|
||||
AssetErrorInsertDepreciationOptionsForMode=Error when inserting the '%s' depreciation mode options
|
||||
AssetErrorFetchDepreciationLines=Error when retrieving recorded depreciation lines
|
||||
AssetErrorClearDepreciationLines=Error when purging recorded depreciation lines (reversal and future)
|
||||
AssetErrorAddDepreciationLine=Error when adding a depreciation line
|
||||
AssetErrorCalculationDepreciationLines=Error when calculating the depreciation lines (recovery and future)
|
||||
AssetErrorReversalDateNotProvidedForMode=The reversal date is not provided for the '%s' depreciation method
|
||||
AssetErrorReversalDateNotGreaterThanCurrentBeginFiscalDateForMode=The reversal date must be greater than or equal to the beginning of the current fiscal year for the '%s' depreciation method
|
||||
AssetErrorReversalAmountNotProvidedForMode=The reversal amount is not provided for the depreciation mode '%s'.
|
||||
AssetErrorFetchCumulativeDepreciation=Error when retrieving the accumulated depreciation amount from the depreciation line
|
||||
AssetErrorSetLastCumulativeDepreciation=Error when recording the last accumulated depreciation amount
|
||||
|
||||
@ -183,4 +183,5 @@ NoBankAccountDefined=No bank account defined
|
||||
NoRecordFoundIBankcAccount=No record found in bank account. Commonly, this occurs when a record has been deleted manually from the list of transaction in the bank account (for example during a reconciliation of the bank account). Another reason is that the payment was recorded when the module "%s" was disabled.
|
||||
AlreadyOneBankAccount=Already one bank account defined
|
||||
SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation=SEPA transfer: 'Payment Type' at 'Credit Transfer' level
|
||||
SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp=SEPA XML: PaymentTypeInformation is mandatory and can now be placed at CreditTransferTransactionInformation level (instead of Payment level). We strongly recommend to place PaymentTypeInformation at Payment level, as all banks will not necessarily accept it at CreditTransferTransactionInformation level. Contact your bank before placing PaymentTypeInformation at CreditTransferTransactionInformation level.
|
||||
SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp=SEPA XML: PaymentTypeInformation is mandatory and can now be placed at CreditTransferTransactionInformation level (instead of Payment level). We strongly recommend to place PaymentTypeInformation at Payment level, as all banks will not necessarily accept it at CreditTransferTransactionInformation level. Contact your bank before placing PaymentTypeInformation at CreditTransferTransactionInformation level.
|
||||
ToCreateRelatedRecordIntoBank=To create missing related bank record
|
||||
|
||||
@ -67,7 +67,7 @@ ErrorDestinationAlreadyExists=Another file with the name <b>%s</b> already exist
|
||||
ErrorPartialFile=File not received completely by server.
|
||||
ErrorNoTmpDir=Temporary directy %s does not exists.
|
||||
ErrorUploadBlockedByAddon=Upload blocked by a PHP/Apache plugin.
|
||||
ErrorFileSizeTooLarge=File size is too large.
|
||||
ErrorFileSizeTooLarge=File size is too large or file not provided.
|
||||
ErrorFieldTooLong=Field %s is too long.
|
||||
ErrorSizeTooLongForIntType=Size too long for int type (%s digits maximum)
|
||||
ErrorSizeTooLongForVarcharType=Size too long for string type (%s chars maximum)
|
||||
|
||||
@ -1165,3 +1165,5 @@ NotClosedYet=Not yet closed
|
||||
ClearSignature=Reset signature
|
||||
CanceledHidden=Canceled hidden
|
||||
CanceledShown=Canceled shown
|
||||
Terminate=Terminate
|
||||
Terminated=Terminated
|
||||
|
||||
@ -254,7 +254,7 @@ ReOpen=Reopen
|
||||
ConfirmFinish=Do you confirm the closing of the inventory ? This will generate all stock movements to update your stock to the real qty you entered into the inventory.
|
||||
ObjectNotFound=%s not found
|
||||
MakeMovementsAndClose=Generate movements and close
|
||||
AutofillWithExpected=Replace real quantity with expected quantity
|
||||
AutofillWithExpected=Fill real quantity with expected quantity
|
||||
ShowAllBatchByDefault=By default, show batch details on product "stock" tab
|
||||
CollapseBatchDetailHelp=You can set batch detail default display in stocks module configuration
|
||||
ErrorWrongBarcodemode=Unknown Barcode mode
|
||||
@ -270,4 +270,5 @@ ErrorOnElementsInventory=Operation canceled for the following reason:
|
||||
ErrorCantFindCodeInInventory=Can't find the following code in inventory
|
||||
QtyWasAddedToTheScannedBarcode=Success !! The quantity was added to all the requested barcode. You can close the Scanner tool.
|
||||
StockChangeDisabled=Change on stock disabled
|
||||
NoWarehouseDefinedForTerminal=No warehouse defined for terminal
|
||||
NoWarehouseDefinedForTerminal=No warehouse defined for terminal
|
||||
ClearQtys=Clear all quantities
|
||||
@ -503,7 +503,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt(
|
||||
// If token is not provided or empty, error (we are in case it is mandatory)
|
||||
if (!GETPOST('token', 'alpha') || GETPOST('token', 'alpha') == 'notrequired') {
|
||||
if (GETPOST('uploadform', 'int')) {
|
||||
dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused. File size too large.");
|
||||
dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused. File size too large or not provided.");
|
||||
$langs->loadLangs(array("errors", "install"));
|
||||
print $langs->trans("ErrorFileSizeTooLarge").' ';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
|
||||
@ -118,7 +118,7 @@ class Partnership extends CommonObject
|
||||
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
|
||||
'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,),
|
||||
'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,),
|
||||
'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '9'=>'Canceled'),),
|
||||
'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '9'=>'Terminated'),),
|
||||
'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',),
|
||||
'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-2,),
|
||||
'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,),
|
||||
@ -1085,12 +1085,12 @@ class Partnership extends CommonObject
|
||||
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
|
||||
$this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
|
||||
$this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
|
||||
$this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled');
|
||||
$this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
|
||||
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
|
||||
$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
|
||||
$this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
|
||||
$this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
|
||||
$this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled');
|
||||
$this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
|
||||
}
|
||||
|
||||
$statusType = 'status'.$status;
|
||||
|
||||
@ -64,7 +64,7 @@ class PartnershipUtils
|
||||
{
|
||||
global $conf, $langs, $user;
|
||||
|
||||
$managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR;
|
||||
$managedfor = empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) ? 'thirdparty' : $conf->global->PARTNERSHIP_IS_MANAGED_FOR;
|
||||
|
||||
if ($managedfor != 'member') {
|
||||
return 0; // If option 'PARTNERSHIP_IS_MANAGED_FOR' = 'thirdparty', this cron job does nothing.
|
||||
|
||||
@ -79,13 +79,14 @@ $permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd &
|
||||
$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php
|
||||
$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1];
|
||||
$managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR;
|
||||
$managedfor = empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) ? 'thirdparty' : $conf->global->PARTNERSHIP_IS_MANAGED_FOR;
|
||||
|
||||
if (empty($conf->partnership->enabled)) accessforbidden();
|
||||
if (empty($permissiontoread)) accessforbidden();
|
||||
if ($object->id > 0 && $object->fk_member > 0 && $managedfor != 'member') accessforbidden();
|
||||
if ($object->id > 0 && $object->fk_soc > 0 && $managedfor != 'thirdparty') accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
@ -578,7 +579,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
// Approve
|
||||
if ($object->status == $object::STATUS_VALIDATED) {
|
||||
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
|
||||
print dolGetButtonAction($langs->trans('Approved'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_accept&confirm=yes&token='.newToken(), '', $permissiontoadd);
|
||||
print dolGetButtonAction($langs->trans('Approve'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_accept&confirm=yes&token='.newToken(), '', $permissiontoadd);
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Approved"), 'default', '#', '', 0);
|
||||
@ -588,7 +589,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
// Cancel
|
||||
if ($permissiontoadd) {
|
||||
if ($object->status == $object::STATUS_APPROVED) {
|
||||
print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
|
||||
print dolGetButtonAction($langs->trans('Resiliate'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
|
||||
} elseif ($object->status > $object::STATUS_APPROVED) {
|
||||
// print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken().'">'.$langs->trans("Re-Open").'</a>'."\n";
|
||||
print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken(), '', $permissiontoadd);
|
||||
|
||||
@ -74,7 +74,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
||||
|
||||
$managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR;
|
||||
$managedfor = empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) ? 'thirdparty' : $conf->global->PARTNERSHIP_IS_MANAGED_FOR;
|
||||
|
||||
if ($managedfor != 'member' && $sortfield == 'd.datefin') $sortfield = '';
|
||||
|
||||
|
||||
@ -428,13 +428,13 @@ class Productbatch extends CommonObject
|
||||
/**
|
||||
* Return all batch detail records for a given product and warehouse
|
||||
*
|
||||
* @param DoliDB $db database object
|
||||
* @param DoliDB $dbs database object
|
||||
* @param int $fk_product_stock id product_stock for objet
|
||||
* @param int $with_qty 1 = doesn't return line with 0 quantity
|
||||
* @param int $fk_product If set to a product id, get eatby and sellby from table llx_product_lot
|
||||
* @return array <0 if KO, array of batch
|
||||
*/
|
||||
public static function findAll($db, $fk_product_stock, $with_qty = 0, $fk_product = 0)
|
||||
public static function findAll($dbs, $fk_product_stock, $with_qty = 0, $fk_product = 0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -453,9 +453,9 @@ class Productbatch extends CommonObject
|
||||
$sql .= ", pl.rowid as lotid, pl.eatby as eatby, pl.sellby as sellby";
|
||||
// TODO May add extrafields to ?
|
||||
}
|
||||
$sql .= " FROM ".$db->prefix()."product_batch as t";
|
||||
$sql .= " FROM ".$dbs->prefix()."product_batch as t";
|
||||
if ($fk_product > 0) {
|
||||
$sql .= " LEFT JOIN ".$db->prefix()."product_lot as pl ON pl.fk_product = ".((int) $fk_product)." AND pl.batch = t.batch";
|
||||
$sql .= " LEFT JOIN ".$dbs->prefix()."product_lot as pl ON pl.fk_product = ".((int) $fk_product)." AND pl.batch = t.batch";
|
||||
// TODO May add extrafields to ?
|
||||
}
|
||||
$sql .= " WHERE fk_product_stock=".((int) $fk_product_stock);
|
||||
@ -470,20 +470,20 @@ class Productbatch extends CommonObject
|
||||
$sql .= ", t.qty ".(!empty($conf->global->DO_NOT_TRY_TO_DEFRAGMENT_STOCKS_WAREHOUSE)?'DESC':'ASC'); // Note : qty ASC is important for expedition card, to avoid stock fragmentation
|
||||
|
||||
dol_syslog("productbatch::findAll", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
$resql = $dbs->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$num = $dbs->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$obj = $dbs->fetch_object($resql);
|
||||
|
||||
$tmp = new Productbatch($db);
|
||||
$tmp = new Productbatch($dbs);
|
||||
$tmp->id = $obj->rowid;
|
||||
$tmp->lotid = $obj->lotid;
|
||||
$tmp->tms = $db->jdate($obj->tms);
|
||||
$tmp->tms = $dbs->jdate($obj->tms);
|
||||
$tmp->fk_product_stock = $obj->fk_product_stock;
|
||||
$tmp->sellby = $db->jdate($obj->sellby ? $obj->sellby : $obj->oldsellby);
|
||||
$tmp->eatby = $db->jdate($obj->eatby ? $obj->eatby : $obj->oldeatby);
|
||||
$tmp->sellby = $dbs->jdate($obj->sellby ? $obj->sellby : $obj->oldsellby);
|
||||
$tmp->eatby = $dbs->jdate($obj->eatby ? $obj->eatby : $obj->oldeatby);
|
||||
$tmp->batch = $obj->batch;
|
||||
$tmp->qty = $obj->qty;
|
||||
$tmp->import_key = $obj->import_key;
|
||||
@ -491,11 +491,11 @@ class Productbatch extends CommonObject
|
||||
$ret[$tmp->batch] = $tmp; // $ret is for a $fk_product_stock and unique key is on $fk_product_stock+batch
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
$dbs->free($resql);
|
||||
|
||||
return $ret;
|
||||
} else {
|
||||
$error = "Error ".$db->lasterror();
|
||||
$error = "Error ".$dbs->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -503,7 +503,6 @@ class Productbatch extends CommonObject
|
||||
/**
|
||||
* Return all batch for a product and a warehouse
|
||||
*
|
||||
* @param DoliDB $db Database object
|
||||
* @param int $fk_product Id of product
|
||||
* @param int $fk_warehouse Id of warehouse
|
||||
* @param int $qty_min [=NULL] Minimum quantity
|
||||
@ -513,7 +512,7 @@ class Productbatch extends CommonObject
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function findAllForProduct($db, $fk_product, $fk_warehouse = 0, $qty_min = null, $sortfield = null, $sortorder = null)
|
||||
public function findAllForProduct($fk_product, $fk_warehouse = 0, $qty_min = null, $sortfield = null, $sortorder = null)
|
||||
{
|
||||
$productBatchList = array();
|
||||
|
||||
@ -526,10 +525,10 @@ class Productbatch extends CommonObject
|
||||
$sql .= ", pl.sellby";
|
||||
$sql .= ", pl.eatby";
|
||||
$sql .= ", pb.qty";
|
||||
$sql .= " FROM ".$db->prefix()."product_lot as pl";
|
||||
$sql .= " LEFT JOIN ".$db->prefix()."product as p ON p.rowid = pl.fk_product";
|
||||
$sql .= " LEFT JOIN ".$db->prefix()."product_batch AS pb ON pl.batch = pb.batch";
|
||||
$sql .= " LEFT JOIN ".$db->prefix()."product_stock AS ps ON ps.rowid = pb.fk_product_stock";
|
||||
$sql .= " FROM ".$this->db->prefix()."product_lot as pl";
|
||||
$sql .= " LEFT JOIN ".$this->db->prefix()."product as p ON p.rowid = pl.fk_product";
|
||||
$sql .= " LEFT JOIN ".$this->db->prefix()."product_batch AS pb ON pl.batch = pb.batch";
|
||||
$sql .= " LEFT JOIN ".$this->db->prefix()."product_stock AS ps ON ps.rowid = pb.fk_product_stock";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('product').")";
|
||||
$sql .= " AND pl.fk_product = ".((int) $fk_product);
|
||||
if ($fk_warehouse > 0) {
|
||||
@ -538,25 +537,25 @@ class Productbatch extends CommonObject
|
||||
if ($qty_min !== null) {
|
||||
$sql .= " AND pb.qty > ".((float) price2num($qty_min, 'MS'));
|
||||
}
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
while ($obj = $db->fetch_object($resql)) {
|
||||
$productBatch = new self($db);
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$productBatch = new self($this->db);
|
||||
$productBatch->id = $obj->rowid;
|
||||
$productBatch->fk_product = $obj->fk_product;
|
||||
$productBatch->batch = $obj->batch;
|
||||
$productBatch->eatby = $db->jdate($obj->eatby);
|
||||
$productBatch->sellby = $db->jdate($obj->sellby);
|
||||
$productBatch->eatby = $this->db->jdate($obj->eatby);
|
||||
$productBatch->sellby = $this->db->jdate($obj->sellby);
|
||||
$productBatch->qty = $obj->qty;
|
||||
$productBatchList[] = $productBatch;
|
||||
}
|
||||
$db->free($resql);
|
||||
$this->db->free($resql);
|
||||
|
||||
return $productBatchList;
|
||||
} else {
|
||||
dol_syslog(__METHOD__.' Error: '.$db->lasterror(), LOG_ERR);
|
||||
dol_syslog(__METHOD__.' Error: '.$this->db->lasterror(), LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -699,7 +699,7 @@ if ($search_opp_percent != '') {
|
||||
if ($search_public != '') {
|
||||
$param .= '&search_public='.urlencode($search_public);
|
||||
}
|
||||
if ($search_project_user != '') {
|
||||
if ($search_project_user > 0) {
|
||||
$param .= '&search_project_user='.urlencode($search_project_user);
|
||||
}
|
||||
if ($search_project_contact != '') {
|
||||
|
||||
@ -491,12 +491,10 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.rowid = ee.fk_target";
|
||||
if (empty($user->rights->societe->client->voir) && !$socid) { // Internal user with no permission to see all
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
|
||||
// Add joins from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook
|
||||
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
|
||||
$sql .= " WHERE e.entity IN (".getEntity('reception').")";
|
||||
if (empty($user->rights->societe->client->voir) && !$socid) { // Internal user with no permission to see all
|
||||
$sql .= " AND e.fk_soc = sc.fk_soc";
|
||||
@ -983,6 +981,9 @@ while ($i < min($num, $limit)) {
|
||||
{
|
||||
}*/
|
||||
print "</td>\n";
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) {
|
||||
@ -1078,6 +1079,13 @@ if ($num == 0) {
|
||||
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
||||
}
|
||||
|
||||
// Show total line
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
|
||||
|
||||
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print "</table>";
|
||||
print "</div>";
|
||||
print '</form>';
|
||||
|
||||
@ -41,6 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonincoterm.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage third parties objects (customers, suppliers, prospects...)
|
||||
*/
|
||||
@ -2573,7 +2574,7 @@ class Societe extends CommonObject
|
||||
$name .= ' ('.$this->name_alias.')';
|
||||
}
|
||||
|
||||
$result = ''; $label = '';
|
||||
$result = ''; $label = ''; $label2 = '';
|
||||
$linkstart = ''; $linkend = '';
|
||||
|
||||
if (!empty($this->logo) && class_exists('Form')) {
|
||||
@ -2641,47 +2642,48 @@ class Societe extends CommonObject
|
||||
}
|
||||
$label .= '<br>'.implode(' ', $phonelist);
|
||||
}
|
||||
|
||||
if (!empty($this->address)) {
|
||||
$label .= '<br><b>'.$langs->trans("Address").':</b> '.dol_format_address($this, 1, ' ', $langs); // Address + country
|
||||
$label2 .= '<br><b>'.$langs->trans("Address").':</b> '.dol_format_address($this, 1, ' ', $langs); // Address + country
|
||||
} elseif (!empty($this->country_code)) {
|
||||
$label .= '<br><b>'.$langs->trans('Country').':</b> '.$this->country_code;
|
||||
$label2 .= '<br><b>'.$langs->trans('Country').':</b> '.$this->country_code;
|
||||
}
|
||||
if (!empty($this->tva_intra) || (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP) && strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'vatnumber') !== false)) {
|
||||
$label .= '<br><b>'.$langs->trans('VATIntra').':</b> '.dol_escape_htmltag($this->tva_intra);
|
||||
$label2 .= '<br><b>'.$langs->trans('VATIntra').':</b> '.dol_escape_htmltag($this->tva_intra);
|
||||
}
|
||||
if (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP)) {
|
||||
if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid1') !== false) {
|
||||
$label .= '<br><b>'.$langs->trans('ProfId1'.$this->country_code).':</b> '.$this->idprof1;
|
||||
$label2 .= '<br><b>'.$langs->trans('ProfId1'.$this->country_code).':</b> '.$this->idprof1;
|
||||
}
|
||||
if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid2') !== false) {
|
||||
$label .= '<br><b>'.$langs->trans('ProfId2'.$this->country_code).':</b> '.$this->idprof2;
|
||||
$label2 .= '<br><b>'.$langs->trans('ProfId2'.$this->country_code).':</b> '.$this->idprof2;
|
||||
}
|
||||
if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid3') !== false) {
|
||||
$label .= '<br><b>'.$langs->trans('ProfId3'.$this->country_code).':</b> '.$this->idprof3;
|
||||
$label2 .= '<br><b>'.$langs->trans('ProfId3'.$this->country_code).':</b> '.$this->idprof3;
|
||||
}
|
||||
if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid4') !== false) {
|
||||
$label .= '<br><b>'.$langs->trans('ProfId4'.$this->country_code).':</b> '.$this->idprof4;
|
||||
$label2 .= '<br><b>'.$langs->trans('ProfId4'.$this->country_code).':</b> '.$this->idprof4;
|
||||
}
|
||||
if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid5') !== false) {
|
||||
$label .= '<br><b>'.$langs->trans('ProfId5'.$this->country_code).':</b> '.$this->idprof5;
|
||||
$label2 .= '<br><b>'.$langs->trans('ProfId5'.$this->country_code).':</b> '.$this->idprof5;
|
||||
}
|
||||
if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid6') !== false) {
|
||||
$label .= '<br><b>'.$langs->trans('ProfId6'.$this->country_code).':</b> '.$this->idprof6;
|
||||
$label2 .= '<br><b>'.$langs->trans('ProfId6'.$this->country_code).':</b> '.$this->idprof6;
|
||||
}
|
||||
}
|
||||
if (!empty($this->code_client) && ($this->client == 1 || $this->client == 3)) {
|
||||
$label .= '<br><b>'.$langs->trans('CustomerCode').':</b> '.$this->code_client;
|
||||
$label2 .= '<br><b>'.$langs->trans('CustomerCode').':</b> '.$this->code_client;
|
||||
}
|
||||
if (!empty($this->code_fournisseur) && $this->fournisseur) {
|
||||
$label .= '<br><b>'.$langs->trans('SupplierCode').':</b> '.$this->code_fournisseur;
|
||||
$label2 .= '<br><b>'.$langs->trans('SupplierCode').':</b> '.$this->code_fournisseur;
|
||||
}
|
||||
if (!empty($conf->accounting->enabled) && ($this->client == 1 || $this->client == 3)) {
|
||||
$label .= '<br><b>'.$langs->trans('CustomerAccountancyCode').':</b> '.($this->code_compta ? $this->code_compta : $this->code_compta_client);
|
||||
$label2 .= '<br><b>'.$langs->trans('CustomerAccountancyCode').':</b> '.($this->code_compta ? $this->code_compta : $this->code_compta_client);
|
||||
}
|
||||
if (!empty($conf->accounting->enabled) && $this->fournisseur) {
|
||||
$label .= '<br><b>'.$langs->trans('SupplierAccountancyCode').':</b> '.$this->code_compta_fournisseur;
|
||||
$label2 .= '<br><b>'.$langs->trans('SupplierAccountancyCode').':</b> '.$this->code_compta_fournisseur;
|
||||
}
|
||||
$label .= '</div>';
|
||||
$label .= ($label2 ? '<br>'.$label2 : '').'</div>';
|
||||
|
||||
// Add type of canvas
|
||||
$linkstart .= (!empty($this->canvas) ? '&canvas='.$this->canvas : '');
|
||||
|
||||
@ -5246,7 +5246,7 @@ td.cal_other_month {
|
||||
/* ============================================================================== */
|
||||
|
||||
/* CSS for treeview */
|
||||
.treeview ul { background-color: transparent !important; margin-bottom: 4px !important; margin-top: 0 !important; padding-top: 8px !important; }
|
||||
.treeview ul { background-color: transparent !important; margin-bottom: 4px !important; margin-top: 0 !important; padding-top: 2px !important; }
|
||||
.treeview li { background-color: transparent !important; padding: 0 0 0 16px !important; min-height: 30px; }
|
||||
.treeview .hover { color: var(--colortextlink) !important; text-decoration: underline !important; }
|
||||
.treeview .hitarea { margin-top: 3px; }
|
||||
@ -6266,7 +6266,7 @@ span.noborderoncategories a, li.noborderoncategories a {
|
||||
/* vertical-align: top; */
|
||||
}
|
||||
span.noborderoncategories {
|
||||
padding: 4px 5px 0px 5px;
|
||||
padding: 3px 5px 3px 5px;
|
||||
display: inline-block;
|
||||
}
|
||||
.categtextwhite, .treeview .categtextwhite.hover {
|
||||
|
||||
@ -6145,7 +6145,7 @@ span.noborderoncategories a, li.noborderoncategories a {
|
||||
line-height: normal;
|
||||
}
|
||||
span.noborderoncategories {
|
||||
padding: 3px 5px 0px 5px;
|
||||
padding: 3px 5px 3px 5px;
|
||||
}
|
||||
.categtextwhite, .treeview .categtextwhite.hover {
|
||||
color: #fff !important;
|
||||
|
||||
@ -917,7 +917,7 @@ if ($action == 'create' || $action == 'adduserldap') {
|
||||
$defaultemployee = '1';
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('Employee').'</td><td>';
|
||||
print '<input type="checkbox" name="employee" value="1"'.(GETPOST('employee') == '1' ? ' checked="checked"' : ($defaultemployee ? ' checked="checked"' : '')).'>';
|
||||
print '<input type="checkbox" name="employee" value="1"'.(GETPOST('employee') == '1' ? ' checked="checked"' : (($defaultemployee && !GETPOSTISSET('login')) ? ' checked="checked"' : '')).'>';
|
||||
//print $form->selectyesno("employee", (GETPOST('employee') != '' ?GETPOST('employee') : $defaultemployee), 1);
|
||||
print '</td></tr>';
|
||||
|
||||
@ -1825,75 +1825,112 @@ if ($action == 'create' || $action == 'adduserldap') {
|
||||
/*
|
||||
* Buttons actions
|
||||
*/
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) {
|
||||
if (empty($user->socid)) {
|
||||
$canSendMail = false;
|
||||
$params = array(
|
||||
'attr' => array(
|
||||
'title' => '',
|
||||
'class' => 'classfortooltip'
|
||||
)
|
||||
);
|
||||
if (!empty($object->email)) {
|
||||
$langs->load("mails");
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
|
||||
$canSendMail = true;
|
||||
} else {
|
||||
$langs->load("mails");
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans('SendMail').'</a></div>';
|
||||
$params['attr']['title'] = $langs->trans('NoEMail');
|
||||
}
|
||||
print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle', '', $canSendMail, $params);
|
||||
}
|
||||
|
||||
if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) {
|
||||
$params = array(
|
||||
'attr' => array(
|
||||
'title' => '',
|
||||
'class' => 'classfortooltip'
|
||||
)
|
||||
);
|
||||
if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("DisabledInMonoUserMode")).'">'.$langs->trans("Modify").'</a></div>';
|
||||
$params['attr']['title'] = $langs->trans('DisabledInMonoUserMode');
|
||||
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
|
||||
} else {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a></div>';
|
||||
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken(), '', true, $params);
|
||||
}
|
||||
} elseif ($caneditpassword && !$object->ldap_sid &&
|
||||
(empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("EditPassword").'</a></div>';
|
||||
$params = array(
|
||||
'attr' => array(
|
||||
'title' => '',
|
||||
'class' => 'classfortooltip'
|
||||
)
|
||||
);
|
||||
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit', '', true, $params);
|
||||
}
|
||||
|
||||
// Si on a un gestionnaire de generation de mot de passe actif
|
||||
$params = array(
|
||||
'attr' => array(
|
||||
'title' => '',
|
||||
'class' => 'classfortooltip'
|
||||
)
|
||||
);
|
||||
if ($conf->global->USER_PASSWORD_GENERATED != 'none') {
|
||||
if ($object->statut == 0) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("UserDisabled")).'">'.$langs->trans("ReinitPassword").'</a></div>';
|
||||
} elseif ($caneditpassword && $object->login && !$object->ldap_sid &&
|
||||
$params['attr']['title'] = $langs->trans('UserDisabled');
|
||||
print dolGetButtonAction($langs->trans('ReinitPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
|
||||
} elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=password&token='.newToken().'">'.$langs->trans("ReinitPassword").'</a></div>';
|
||||
print dolGetButtonAction($langs->trans('ReinitPassword'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=password&token='.newToken(), '', true, $params);
|
||||
}
|
||||
|
||||
if ($object->statut == 0) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("UserDisabled")).'">'.$langs->trans("SendNewPassword").'</a></div>';
|
||||
} elseif ($caneditpassword && $object->login && !$object->ldap_sid &&
|
||||
$params['attr']['title'] = $langs->trans('UserDisabled');
|
||||
print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
|
||||
} elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) {
|
||||
if ($object->email) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=passwordsend&token='.newToken().'">'.$langs->trans("SendNewPassword").'</a></div>';
|
||||
print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=passwordsend&token='.newToken(), '', true, $params);
|
||||
} else {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendNewPassword").'</a></div>';
|
||||
$params['attr']['title'] = $langs->trans('NoEMail');
|
||||
print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enable user
|
||||
$params = array(
|
||||
'attr' => array(
|
||||
'title' => '',
|
||||
'class' => 'classfortooltip'
|
||||
)
|
||||
);
|
||||
if ($user->id <> $id && $candisableuser && $object->statut == 0 &&
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken().'">'.$langs->trans("Reactivate").'</a></div>';
|
||||
print dolGetButtonAction($langs->trans('Reactivate'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=enable&token='.newToken().$langs->trans("Reactivate"), '', true, $params);
|
||||
}
|
||||
// Disable user
|
||||
if ($user->id <> $id && $candisableuser && $object->statut == 1 &&
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken().'">'.$langs->trans("DisableUser").'</a></div>';
|
||||
print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=disable&token='.newToken().$langs->trans("DisableUser"), '', true, $params);
|
||||
} else {
|
||||
if ($user->id == $id) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("CantDisableYourself").'">'.$langs->trans("DisableUser").'</a></div>';
|
||||
$params['attr']['title'] = $langs->trans('CantDisableYourself');
|
||||
print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
|
||||
}
|
||||
}
|
||||
// Delete
|
||||
if ($user->id <> $id && $candisableuser &&
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) {
|
||||
if ($user->admin || !$object->admin) { // If user edited is admin, delete is possible on for an admin
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans("DeleteUser").'</a></div>';
|
||||
print dolGetButtonAction($langs->trans('DeleteUser'), '', 'default', $_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id, '', true, $params);
|
||||
} else {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("MustBeAdminToDeleteOtherAdmin")).'">'.$langs->trans("DeleteUser").'</a></div>';
|
||||
$params['attr']['title'] = $langs->trans('MustBeAdminToDeleteOtherAdmin');
|
||||
print dolGetButtonAction($langs->trans('DeleteUser'), '', 'default', $_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id, '', false, $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1902,7 +1939,7 @@ if ($action == 'create' || $action == 'adduserldap') {
|
||||
|
||||
|
||||
|
||||
//Select mail models is same action as presend
|
||||
// Select mail models is same action as presend
|
||||
if (GETPOST('modelselected')) {
|
||||
$action = 'presend';
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ if (empty($modulepart)) {
|
||||
accessforbidden('Bad value for parameter modulepart', 0, 0, 1);
|
||||
}
|
||||
|
||||
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname);
|
||||
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $user, $refname);
|
||||
$accessallowed = $check_access['accessallowed'];
|
||||
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
|
||||
$fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name
|
||||
|
||||
@ -211,10 +211,8 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
|
||||
'modules_societe.class.php',
|
||||
'TraceableDB.php',
|
||||
'multicurrency.class.php',
|
||||
'productbatch.class.php',
|
||||
'reception.class.php',
|
||||
'infobox.class.php',
|
||||
'link.class.php',
|
||||
'infobox.class.php'
|
||||
))) {
|
||||
// Must not find $db->
|
||||
$ok=true;
|
||||
@ -231,10 +229,11 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
|
||||
}
|
||||
} else {
|
||||
if (! in_array($file['name'], array(
|
||||
'objectline_view.tpl.php',
|
||||
'extrafieldsinexport.inc.php',
|
||||
'DolQueryCollector.php'
|
||||
))) {
|
||||
// Must must not found $this->db->
|
||||
// Must not found $this->db->
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
// Check string $this->db-> into a non class.php file (it shoud be $db-> into such classes)
|
||||
@ -244,7 +243,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
|
||||
break;
|
||||
}
|
||||
//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
|
||||
$this->assertTrue($ok, 'Found string $this->db-> in '.$file['relativename']);
|
||||
$this->assertTrue($ok, 'Found string "$this->db->" in '.$file['relativename']);
|
||||
//exit;
|
||||
}
|
||||
}
|
||||
@ -324,7 +323,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
|
||||
$ok=false;
|
||||
break;
|
||||
}
|
||||
$this->assertTrue($ok, 'Found a forged SQL string that mix on same line the use of \' for PHP string and PHP variables into file '.$file['relativename'].' Use " to forge PHP string like this: $sql = "SELET ".$myvar...');
|
||||
$this->assertTrue($ok, 'Found a forged SQL string that mix on same line the use of \' for PHP string and PHP variables into file '.$file['relativename'].' Use " to forge PHP string like this: $sql = "SELECT ".$myvar...');
|
||||
|
||||
// Check sql string VALUES ... , ".$xxx
|
||||
// with xxx that is not 'db-' (for $db->escape). It means we forget a ' if string, or an (int) if int, when forging sql request.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user