This commit is contained in:
Alexandre SPANGARO 2022-02-14 04:52:39 +01:00
parent d5e521c87b
commit 6734a3575e
14 changed files with 2545 additions and 77 deletions

View File

@ -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>
@ -3670,7 +3670,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;

View File

@ -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;
}

View File

@ -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 = '';
}
}

View File

@ -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&amp;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&amp;action=create", $langs->trans("MenuNewAsset"), 1, $user->rights->asset->write);
$newmenu->add("/asset/list.php?leftmenu=asset&amp;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&amp;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&amp;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)));
}
}
}

View 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;
}
}

File diff suppressed because it is too large Load Diff

View 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">&nbsp; <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;
}
}

View 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;
}
}

View 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");
}
}

View File

@ -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';
@ -192,13 +192,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
//-------

View File

@ -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

View File

@ -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";

View File

@ -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>';

View File

@ -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)) {