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);
}
// Clone confirmation
/* elseif ($action == 'clone') {
/* 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);

View File

@ -258,89 +258,89 @@ class Asset extends CommonObject
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;
// }
// $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;
// }
return -1;
}
@ -656,7 +656,7 @@ class Asset extends CommonObject
$sql .= " WHERE doc_type = 'asset'";
$sql .= ")";
$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 .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid";
$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 .= " VALUES ( ";
$sql .= " " . (int)$this->id;
$sql .= " " . (int) $this->id;
$sql .= ", '" . $this->db->escape($mode) . "'";
$sql .= ", '" . $this->db->escape($ref) . "'";
$sql .= ", '" . $this->db->idate($depreciation_date) . "'";
$sql .= ", " . (double)$depreciation_ht;
$sql .= ", " . (double)$cumulative_depreciation_ht;
$sql .= ", " . (double) $depreciation_ht;
$sql .= ", " . (double) $cumulative_depreciation_ht;
$sql .= ", '" . $this->db->escape($accountancy_code_debit) . "'";
$sql .= ", '" . $this->db->escape($accountancy_code_credit) . "'";
$sql .= ")";
@ -1021,7 +1021,7 @@ class Asset extends CommonObject
}
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;
} else {
$cumulative_depreciation_ht += $depreciation_ht;
@ -1561,31 +1561,31 @@ class Asset extends CommonObject
* @param null|array $moreparams Array to provide more information
* @return int 0 if KO, 1 if OK
*/
// public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
// {
// global $conf, $langs;
//
// $result = 0;
// $includedocgeneration = 1;
//
// $langs->load("asset@asset");
//
// if (!dol_strlen($modele)) {
// $modele = 'standard_asset';
//
// if (!empty($this->model_pdf)) {
// $modele = $this->model_pdf;
// } elseif (!empty($conf->global->ASSET_ADDON_PDF)) {
// $modele = $conf->global->ASSET_ADDON_PDF;
// }
// }
//
// $modelpath = "core/modules/asset/doc/";
//
// if ($includedocgeneration && !empty($modele)) {
// $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
// }
//
// return $result;
// }
// public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
// {
// global $conf, $langs;
//
// $result = 0;
// $includedocgeneration = 1;
//
// $langs->load("asset@asset");
//
// if (!dol_strlen($modele)) {
// $modele = 'standard_asset';
//
// if (!empty($this->model_pdf)) {
// $modele = $this->model_pdf;
// } elseif (!empty($conf->global->ASSET_ADDON_PDF)) {
// $modele = $conf->global->ASSET_ADDON_PDF;
// }
// }
//
// $modelpath = "core/modules/asset/doc/";
//
// if ($includedocgeneration && !empty($modele)) {
// $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
// }
//
// return $result;
// }
}

View File

@ -461,9 +461,9 @@ class AssetModel extends CommonObject
$sql .= ", date_validation = '" . $this->db->idate($now) . "'";
}
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);
$resql = $this->db->query($sql);

View File

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

View File

@ -181,35 +181,35 @@ if ($object->id > 0) {
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>';
// }
// }
// 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);
// }
// 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

View File

@ -313,14 +313,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
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);
// $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>';
}