Merge branch '16a12_assets_code' of https://github.com/aspangaro/dolibarr into 16a12_assets_code

This commit is contained in:
Alexandre SPANGARO 2022-02-14 05:34:06 +01:00
commit b7d26c2e5c
10 changed files with 254 additions and 254 deletions

View File

@ -293,7 +293,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('AssetConfirmReOpenAsk', $object->ref), 'confirm_reopen', $formquestion, 'yes', 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('AssetConfirmReOpenAsk', $object->ref), 'confirm_reopen', $formquestion, 'yes', 1);
} }
// Clone confirmation // Clone confirmation
/* elseif ($action == 'clone') { /* elseif ($action == 'clone') {
// Create an array for form // Create an array for form
$formquestion = array(); $formquestion = array();
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);

View File

@ -258,89 +258,89 @@ class Asset extends CommonObject
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
// $object = new self($this->db); // $object = new self($this->db);
// //
// $this->db->begin(); // $this->db->begin();
// //
// // Load source object // // Load source object
// $result = $object->fetchCommon($fromid); // $result = $object->fetchCommon($fromid);
// if ($result > 0 && !empty($object->table_element_line)) { // if ($result > 0 && !empty($object->table_element_line)) {
// $object->fetchLines(); // $object->fetchLines();
// } // }
// //
// // get lines so they will be clone // // get lines so they will be clone
// //foreach($this->lines as $line) // //foreach($this->lines as $line)
// // $line->fetch_optionals(); // // $line->fetch_optionals();
// //
// // Reset some properties // // Reset some properties
// unset($object->id); // unset($object->id);
// unset($object->fk_user_creat); // unset($object->fk_user_creat);
// unset($object->import_key); // unset($object->import_key);
// //
// // Clear fields // // Clear fields
// if (property_exists($object, 'ref')) { // if (property_exists($object, 'ref')) {
// $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; // $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
// } // }
// if (property_exists($object, 'label')) { // if (property_exists($object, 'label')) {
// $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; // $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
// } // }
// if (property_exists($object, 'status')) { // if (property_exists($object, 'status')) {
// $object->status = self::STATUS_DRAFT; // $object->status = self::STATUS_DRAFT;
// } // }
// if (property_exists($object, 'date_creation')) { // if (property_exists($object, 'date_creation')) {
// $object->date_creation = dol_now(); // $object->date_creation = dol_now();
// } // }
// if (property_exists($object, 'date_modification')) { // if (property_exists($object, 'date_modification')) {
// $object->date_modification = null; // $object->date_modification = null;
// } // }
// // ... // // ...
// // Clear extrafields that are unique // // Clear extrafields that are unique
// if (is_array($object->array_options) && count($object->array_options) > 0) { // if (is_array($object->array_options) && count($object->array_options) > 0) {
// $extrafields->fetch_name_optionals_label($this->table_element); // $extrafields->fetch_name_optionals_label($this->table_element);
// foreach ($object->array_options as $key => $option) { // foreach ($object->array_options as $key => $option) {
// $shortkey = preg_replace('/options_/', '', $key); // $shortkey = preg_replace('/options_/', '', $key);
// if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { // if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
// //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; // //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
// unset($object->array_options[$key]); // unset($object->array_options[$key]);
// } // }
// } // }
// } // }
// //
// // Create clone // // Create clone
// $object->context['createfromclone'] = 'createfromclone'; // $object->context['createfromclone'] = 'createfromclone';
// $result = $object->createCommon($user); // $result = $object->createCommon($user);
// if ($result < 0) { // if ($result < 0) {
// $error++; // $error++;
// $this->error = $object->error; // $this->error = $object->error;
// $this->errors = $object->errors; // $this->errors = $object->errors;
// } // }
// //
// if (!$error) { // if (!$error) {
// // copy internal contacts // // copy internal contacts
// if ($this->copy_linked_contact($object, 'internal') < 0) { // if ($this->copy_linked_contact($object, 'internal') < 0) {
// $error++; // $error++;
// } // }
// } // }
// //
// if (!$error) { // if (!$error) {
// // copy external contacts if same company // // copy external contacts if same company
// if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { // if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
// if ($this->copy_linked_contact($object, 'external') < 0) { // if ($this->copy_linked_contact($object, 'external') < 0) {
// $error++; // $error++;
// } // }
// } // }
// } // }
// //
// unset($object->context['createfromclone']); // unset($object->context['createfromclone']);
// //
// // End // // End
// if (!$error) { // if (!$error) {
// $this->db->commit(); // $this->db->commit();
// return $object; // return $object;
// } else { // } else {
// $this->db->rollback(); // $this->db->rollback();
// return -1; // return -1;
// } // }
return -1; return -1;
} }
@ -656,7 +656,7 @@ class Asset extends CommonObject
$sql .= " WHERE doc_type = 'asset'"; $sql .= " WHERE doc_type = 'asset'";
$sql .= ")"; $sql .= ")";
$sql .= "SELECT ad.rowid, ad.depreciation_mode, ad.ref, ad.depreciation_date, ad.depreciation_ht, ad.cumulative_depreciation_ht"; $sql .= "SELECT ad.rowid, ad.depreciation_mode, ad.ref, ad.depreciation_date, ad.depreciation_ht, ad.cumulative_depreciation_ht";
$sql .= ", " . $this->db->ifsql('iab.fk_docdet IS NOT NULL', 1 , 0) . " AS bookkeeping"; $sql .= ", " . $this->db->ifsql('iab.fk_docdet IS NOT NULL', 1, 0) . " AS bookkeeping";
$sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad"; $sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad";
$sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid"; $sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid";
$sql .= " WHERE ad.fk_asset = " . $this->id; $sql .= " WHERE ad.fk_asset = " . $this->id;
@ -766,12 +766,12 @@ class Asset extends CommonObject
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "asset_depreciation(fk_asset, depreciation_mode, ref, depreciation_date, depreciation_ht, cumulative_depreciation_ht, accountancy_code_debit, accountancy_code_credit)"; $sql = "INSERT INTO " . MAIN_DB_PREFIX . "asset_depreciation(fk_asset, depreciation_mode, ref, depreciation_date, depreciation_ht, cumulative_depreciation_ht, accountancy_code_debit, accountancy_code_credit)";
$sql .= " VALUES ( "; $sql .= " VALUES ( ";
$sql .= " " . (int)$this->id; $sql .= " " . (int) $this->id;
$sql .= ", '" . $this->db->escape($mode) . "'"; $sql .= ", '" . $this->db->escape($mode) . "'";
$sql .= ", '" . $this->db->escape($ref) . "'"; $sql .= ", '" . $this->db->escape($ref) . "'";
$sql .= ", '" . $this->db->idate($depreciation_date) . "'"; $sql .= ", '" . $this->db->idate($depreciation_date) . "'";
$sql .= ", " . (double)$depreciation_ht; $sql .= ", " . (double) $depreciation_ht;
$sql .= ", " . (double)$cumulative_depreciation_ht; $sql .= ", " . (double) $cumulative_depreciation_ht;
$sql .= ", '" . $this->db->escape($accountancy_code_debit) . "'"; $sql .= ", '" . $this->db->escape($accountancy_code_debit) . "'";
$sql .= ", '" . $this->db->escape($accountancy_code_credit) . "'"; $sql .= ", '" . $this->db->escape($accountancy_code_credit) . "'";
$sql .= ")"; $sql .= ")";
@ -1021,7 +1021,7 @@ class Asset extends CommonObject
} }
if ($fiscal_period_start <= $depreciation_date_end && $depreciation_date_end <= $fiscal_period_end) { // last period if ($fiscal_period_start <= $depreciation_date_end && $depreciation_date_end <= $fiscal_period_end) { // last period
$depreciation_ht = (double)price2num($depreciation_amount - $cumulative_depreciation_ht, 'MT'); $depreciation_ht = (double) price2num($depreciation_amount - $cumulative_depreciation_ht, 'MT');
$cumulative_depreciation_ht = $depreciation_amount; $cumulative_depreciation_ht = $depreciation_amount;
} else { } else {
$cumulative_depreciation_ht += $depreciation_ht; $cumulative_depreciation_ht += $depreciation_ht;
@ -1561,31 +1561,31 @@ class Asset extends CommonObject
* @param null|array $moreparams Array to provide more information * @param null|array $moreparams Array to provide more information
* @return int 0 if KO, 1 if OK * @return int 0 if KO, 1 if OK
*/ */
// public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) // public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
// { // {
// global $conf, $langs; // global $conf, $langs;
// //
// $result = 0; // $result = 0;
// $includedocgeneration = 1; // $includedocgeneration = 1;
// //
// $langs->load("asset@asset"); // $langs->load("asset@asset");
// //
// if (!dol_strlen($modele)) { // if (!dol_strlen($modele)) {
// $modele = 'standard_asset'; // $modele = 'standard_asset';
// //
// if (!empty($this->model_pdf)) { // if (!empty($this->model_pdf)) {
// $modele = $this->model_pdf; // $modele = $this->model_pdf;
// } elseif (!empty($conf->global->ASSET_ADDON_PDF)) { // } elseif (!empty($conf->global->ASSET_ADDON_PDF)) {
// $modele = $conf->global->ASSET_ADDON_PDF; // $modele = $conf->global->ASSET_ADDON_PDF;
// } // }
// } // }
// //
// $modelpath = "core/modules/asset/doc/"; // $modelpath = "core/modules/asset/doc/";
// //
// if ($includedocgeneration && !empty($modele)) { // if ($includedocgeneration && !empty($modele)) {
// $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); // $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
// } // }
// //
// return $result; // return $result;
// } // }
} }

View File

@ -461,9 +461,9 @@ class AssetModel extends CommonObject
$sql .= ", date_validation = '" . $this->db->idate($now) . "'"; $sql .= ", date_validation = '" . $this->db->idate($now) . "'";
} }
if (!empty($this->fields['fk_user_valid'])) { if (!empty($this->fields['fk_user_valid'])) {
$sql .= ", fk_user_valid = " . ((int)$user->id); $sql .= ", fk_user_valid = " . ((int) $user->id);
} }
$sql .= " WHERE rowid = " . ((int)$this->id); $sql .= " WHERE rowid = " . ((int) $this->id);
dol_syslog(get_class($this) . "::validate()", LOG_DEBUG); dol_syslog(get_class($this) . "::validate()", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -142,9 +142,9 @@ if ($object->id) {
$modulepart = 'asset'; $modulepart = 'asset';
$permissiontoadd = $user->rights->asset->write; $permissiontoadd = $user->rights->asset->write;
// $permissiontoadd = 1; // $permissiontoadd = 1;
$permtoedit = $user->rights->asset->write; $permtoedit = $user->rights->asset->write;
// $permtoedit = 1; // $permtoedit = 1;
$param = '&id=' . $object->id; $param = '&id=' . $object->id;
//$relativepathwithnofile='asset/' . dol_sanitizeFileName($object->id).'/'; //$relativepathwithnofile='asset/' . dol_sanitizeFileName($object->id).'/';

View File

@ -181,35 +181,35 @@ if ($object->id > 0) {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
// if (!empty($conf->agenda->enabled)) { // if (!empty($conf->agenda->enabled)) {
// if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { // 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>'; // print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create' . $out . '">' . $langs->trans("AddAction") . '</a>';
// } else { // } else {
// print '<a class="butActionRefused classfortooltip" href="#">' . $langs->trans("AddAction") . '</a>'; // print '<a class="butActionRefused classfortooltip" href="#">' . $langs->trans("AddAction") . '</a>';
// } // }
// } // }
print '</div>'; print '</div>';
// if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { // if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
// $param = '&id=' . $object->id . '&socid=' . $socid; // $param = '&id=' . $object->id . '&socid=' . $socid;
// if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { // if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
// $param .= '&contextpage=' . urlencode($contextpage); // $param .= '&contextpage=' . urlencode($contextpage);
// } // }
// if ($limit > 0 && $limit != $conf->liste_limit) { // if ($limit > 0 && $limit != $conf->liste_limit) {
// $param .= '&limit=' . urlencode($limit); // $param .= '&limit=' . urlencode($limit);
// } // }
// //
// //
// print load_fiche_titre($langs->trans("ActionsOnAssetModel"), '', ''); // print load_fiche_titre($langs->trans("ActionsOnAssetModel"), '', '');
// //
// // List of all actions // // List of all actions
// $filters = array(); // $filters = array();
// $filters['search_agenda_label'] = $search_agenda_label; // $filters['search_agenda_label'] = $search_agenda_label;
// //
// // TODO Replace this with same code than into list.php // // 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); // show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
// } // }
} }
// End of page // End of page

View File

@ -313,14 +313,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</div><div class="fichehalfright">'; print '</div><div class="fichehalfright">';
// $MAXEVENT = 10; // $MAXEVENT = 10;
// //
// $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT . '/asset/model/agenda.php?id=' . $object->id); // $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 // // List of actions on element
// include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; // include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
// $formactions = new FormActions($db); // $formactions = new FormActions($db);
// $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, 0, 1, '', $MAXEVENT, '', $morehtmlright); // $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, 0, 1, '', $MAXEVENT, '', $morehtmlright);
print '</div></div>'; print '</div></div>';
} }