Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
45688e287a
2
.github/workflows/code_quality.yml
vendored
2
.github/workflows/code_quality.yml
vendored
@ -18,7 +18,7 @@ jobs:
|
||||
fetch-depth: 1
|
||||
#php-version: '7.1'
|
||||
- name: 'Qodana Scan'
|
||||
uses: JetBrains/qodana-action@v2022.3.4
|
||||
uses: JetBrains/qodana-action@v2023.1.0
|
||||
#with:
|
||||
# php-version: '7.1'
|
||||
env:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
276
htdocs/accountancy/class/api_accountancy.class.php
Normal file
276
htdocs/accountancy/class/api_accountancy.class.php
Normal file
@ -0,0 +1,276 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2019 Cedric Ancelin <icedo.anc@gmail.com>
|
||||
* Copyright (C) 2023 Lionel Vessiller <lvessiller@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/>.
|
||||
*/
|
||||
|
||||
use Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* API class for accountancy
|
||||
*
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
*
|
||||
*/
|
||||
class Accountancy extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
public static $FIELDS = array();
|
||||
|
||||
/**
|
||||
* @var BookKeeping $bookkeeping {@type BookKeeping}
|
||||
*/
|
||||
public $bookkeeping;
|
||||
|
||||
/**
|
||||
* @var AccountancyExport $accountancy_export {@type AccountancyExport}
|
||||
*/
|
||||
public $accountancyexport;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
global $db, $langs;
|
||||
$this->db = $db;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
|
||||
|
||||
$langs->load('accountancy');
|
||||
|
||||
$this->bookkeeping = new BookKeeping($this->db);
|
||||
$this->accountancyexport = new AccountancyExport($this->db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accountancy export data
|
||||
*
|
||||
* @param string $period Period : 'lastmonth', 'currentmonth', 'last3months', 'last6months', 'currentyear', 'lastyear', 'fiscalyear', 'lastfiscalyear', 'actualandlastfiscalyear' or 'custom' (see above)
|
||||
* @param string $date_min [=''] Start date of period if 'custom' is set in period parameter
|
||||
* Date format is 'YYYY-MM-DD'
|
||||
* @param string $date_max [=''] End date of period if 'custom' is set in period parameter
|
||||
* Date format is 'YYYY-MM-DD'
|
||||
* @param string $format [=''] by default uses '1' for 'Configurable (CSV)' for format number
|
||||
* or '1000' for FEC
|
||||
* or '1010' for FEC2
|
||||
* (see AccountancyExport class)
|
||||
* @param int $lettering [=0] by default don't export or 1 to export lettering data (columns 'letterring_code' and 'date_lettering' returns empty or not)
|
||||
* @param int $alreadyexport [=0] by default export data only if it's not yet exported or 1 already exported (always export data even if 'date_export" is set)
|
||||
* @param int $notnotifiedasexport [=0] by default notified as exported or 1 not notified as exported (when the export is done, notified or not the column 'date_export')
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @url GET exportdata
|
||||
*
|
||||
* @throws RestException 401 Insufficient rights
|
||||
* @throws RestException 404 Accountancy export period not found
|
||||
* @throws RestException 404 Accountancy export start or end date not defined
|
||||
* @throws RestException 404 Accountancy export format not found
|
||||
* @throws RestException 500 Error on accountancy export
|
||||
*/
|
||||
public function exportData($period, $date_min = '', $date_max = '', $format = '', $lettering = 0, $alreadyexport = 0, $notnotifiedasexport = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
// check rights
|
||||
if (!DolibarrApiAccess::$user->rights->accounting->mouvements->export) {
|
||||
throw new RestException(401, 'No permission to export accounting');
|
||||
}
|
||||
|
||||
// check parameters
|
||||
$period_available_list = array('lastmonth', 'currentmonth', 'last3months', 'last6months', 'currentyear', 'lastyear', 'fiscalyear', 'lastfiscalyear', 'actualandlastfiscalyear', 'custom');
|
||||
if (!in_array($period, $period_available_list)) {
|
||||
throw new RestException(404, 'Accountancy export period not found');
|
||||
}
|
||||
if ($period == 'custom') {
|
||||
if ($date_min == '' && $date_max == '') {
|
||||
throw new RestException(404, 'Accountancy export start and end date for custom period not defined');
|
||||
}
|
||||
}
|
||||
if ($format == '') {
|
||||
$format = AccountancyExport::$EXPORT_TYPE_CONFIGURABLE; // uses default
|
||||
}
|
||||
|
||||
// get objects
|
||||
$bookkeeping = $this->bookkeeping;
|
||||
$accountancyexport = $this->accountancyexport;
|
||||
|
||||
// find export format code from format number
|
||||
$format_number_available_list = $accountancyexport->getType();
|
||||
if (is_numeric($format)) {
|
||||
$format_number = (int) $format;
|
||||
} else {
|
||||
$format_number = 0;
|
||||
$format_label_available_list = array_flip($format_number_available_list);
|
||||
if (isset($format_label_available_list[$format])) {
|
||||
$format_number = $format_label_available_list[$format];
|
||||
}
|
||||
}
|
||||
|
||||
// get all format available and check if exists
|
||||
if (!array_key_exists($format_number, $format_number_available_list)) {
|
||||
throw new RestException(404, 'Accountancy export format not found');
|
||||
}
|
||||
|
||||
$sortorder = 'ASC'; // by default
|
||||
$sortfield = 't.piece_num, t.rowid'; // by default
|
||||
|
||||
// set filter for each period available
|
||||
$filter = array();
|
||||
$doc_date_start = null;
|
||||
$doc_date_end= null;
|
||||
$now = dol_now();
|
||||
$now_arr = dol_getdate($now);
|
||||
$now_month = $now_arr['mon'];
|
||||
$now_year = $now_arr['year'];
|
||||
if ($period == 'custom') {
|
||||
if ($date_min != '') {
|
||||
$time_min = strtotime($date_min);
|
||||
if ($time_min !== false) {
|
||||
$doc_date_start = $time_min;
|
||||
}
|
||||
}
|
||||
if ($date_max != '') {
|
||||
$time_max = strtotime($date_max);
|
||||
if ($time_max !== false) {
|
||||
$doc_date_end = $time_max;
|
||||
}
|
||||
}
|
||||
} elseif ($period == 'lastmonth') {
|
||||
$prev_date_arr = dol_get_prev_month($now_month, $now_year); // get previous month and year if month is january
|
||||
$doc_date_start = dol_mktime(0, 0, 0, $prev_date_arr['month'], 1, $prev_date_arr['year']); // first day of previous month
|
||||
$doc_date_end = dol_get_last_day($prev_date_arr['year'], $prev_date_arr['month']); // last day of previous month
|
||||
} elseif ($period == 'currentmonth') {
|
||||
$doc_date_start = dol_mktime(0, 0, 0, $now_month, 1, $now_year); // first day of current month
|
||||
$doc_date_end = dol_get_last_day($now_year, $now_month); // last day of current month
|
||||
} elseif ($period == 'last3months' || $period == 'last6months') {
|
||||
if ($period == 'last3months') {
|
||||
// last 3 months
|
||||
$nb_prev_month = 3;
|
||||
} else {
|
||||
// last 6 months
|
||||
$nb_prev_month = 6;
|
||||
}
|
||||
$prev_month_date_list = array();
|
||||
$prev_month_date_list[] = dol_get_prev_month($now_month, $now_year); // get previous month for index = 0
|
||||
for ($i = 1; $i < $nb_prev_month; $i++) {
|
||||
$prev_month_date_list[] = dol_get_prev_month($prev_month_date_list[$i-1]['month'], $prev_month_date_list[$i-1]['year']); // get i+1 previous month for index=i
|
||||
}
|
||||
$doc_date_start = dol_mktime(0, 0, 0, $prev_month_date_list[$nb_prev_month-1]['month'], 1, $prev_month_date_list[$nb_prev_month-1]['year']); // first day of n previous month for index=n-1
|
||||
$doc_date_end = dol_get_last_day($prev_month_date_list[0]['year'], $prev_month_date_list[0]['month']); // last day of previous month for index = 0
|
||||
} elseif ($period == 'currentyear' || $period == 'lastyear') {
|
||||
$period_year = $now_year;
|
||||
if ($period == 'lastyear') {
|
||||
$period_year--;
|
||||
}
|
||||
$doc_date_start = dol_mktime(0, 0, 0, 1, 1, $period_year); // first day of year
|
||||
$doc_date_end = dol_mktime(23, 59, 59, 12, 31, $period_year); // last day of year
|
||||
} elseif ($period == 'fiscalyear' || $period == 'lastfiscalyear' || $period == 'actualandlastfiscalyear') {
|
||||
// find actual fiscal year
|
||||
$cur_fiscal_period = getCurrentPeriodOfFiscalYear($this->db, $conf);
|
||||
$cur_fiscal_date_start = $cur_fiscal_period['date_start'];
|
||||
$cur_fiscal_date_end = $cur_fiscal_period['date_end'];
|
||||
|
||||
if ($period == 'fiscalyear') {
|
||||
$doc_date_start = $cur_fiscal_date_start;
|
||||
$doc_date_end = $cur_fiscal_date_end;
|
||||
} else {
|
||||
// get one day before current fiscal date start (to find previous fiscal period)
|
||||
$prev_fiscal_date_search = dol_time_plus_duree($cur_fiscal_date_start, -1, 'd');
|
||||
|
||||
// find previous fiscal year from current fiscal year
|
||||
$prev_fiscal_period = getCurrentPeriodOfFiscalYear($this->db, $conf, $prev_fiscal_date_search);
|
||||
$prev_fiscal_date_start = $prev_fiscal_period['date_start'];
|
||||
$prev_fiscal_date_end = $prev_fiscal_period['date_end'];
|
||||
|
||||
if ($period == 'lastfiscalyear') {
|
||||
$doc_date_start = $prev_fiscal_date_start;
|
||||
$doc_date_end = $prev_fiscal_date_end;
|
||||
} else {
|
||||
// period == 'actualandlastfiscalyear'
|
||||
$doc_date_start = $prev_fiscal_date_start;
|
||||
$doc_date_end = $cur_fiscal_date_end;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_numeric($doc_date_start)) {
|
||||
$filter['t.doc_date>='] = $doc_date_start;
|
||||
}
|
||||
if (is_numeric($doc_date_end)) {
|
||||
$filter['t.doc_date<='] = $doc_date_end;
|
||||
}
|
||||
|
||||
$result = $bookkeeping->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $alreadyexport);
|
||||
|
||||
if ($result < 0) {
|
||||
throw new RestException(500, 'Error bookkeeping fetch all : '.$bookkeeping->errorsToString());
|
||||
} else {
|
||||
// export files then exit
|
||||
if (empty($lettering)) {
|
||||
if (is_array($bookkeeping->lines)) {
|
||||
foreach ($bookkeeping->lines as $k => $movement) {
|
||||
unset($bookkeeping->lines[$k]->lettering_code);
|
||||
unset($bookkeeping->lines[$k]->date_lettering);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
$this->db->begin();
|
||||
|
||||
if (empty($notnotifiedasexport)) {
|
||||
if (is_array($bookkeeping->lines)) {
|
||||
foreach ($bookkeeping->lines as $movement) {
|
||||
$now = dol_now();
|
||||
|
||||
$sql = " UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping";
|
||||
$sql .= " SET date_export = '" . $this->db->idate($now) . "'";
|
||||
$sql .= " WHERE rowid = " . ((int) $movement->id);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if (!$result) {
|
||||
$accountancyexport->errors[] = $langs->trans('NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated');
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// export and only write file without downloading
|
||||
if (!$error) {
|
||||
$result = $accountancyexport->export($bookkeeping->lines, $format_number, 0, 1, 2);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
throw new RestException(500, 'Error accountancy export : '.implode(',', $accountancyexport->errors));
|
||||
} else {
|
||||
$this->db->commit();
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
// $formatexportset must be defined
|
||||
// $downloadMode =0 for direct download or =1 to download after writing files or =-1 not to download files
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($conf) || !is_object($conf)) {
|
||||
@ -35,7 +36,7 @@ $siren = getDolGlobalString('MAIN_INFO_SIREN');
|
||||
$date_export = "_".dol_print_date(dol_now(), '%Y%m%d%H%M%S');
|
||||
$endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d');
|
||||
|
||||
if (empty($withAttachment)) {
|
||||
if (empty($downloadMode)) {
|
||||
header('Content-Type: text/csv');
|
||||
}
|
||||
|
||||
@ -70,6 +71,6 @@ if (($accountancyexport->getFormatCode($formatexportset) == 'fec' || $accountanc
|
||||
$completefilename = ($code ? $code."_" : "").($prefix ? $prefix."_" : "").$filename.($nodateexport ? "" : $date_export).".".$format;
|
||||
}
|
||||
|
||||
if (empty($withAttachment)) {
|
||||
if (empty($downloadMode)) {
|
||||
header('Content-Disposition: attachment;filename=' . $completefilename);
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonpeople.class.php';
|
||||
|
||||
|
||||
/**
|
||||
@ -45,6 +46,8 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
*/
|
||||
class Adherent extends CommonObject
|
||||
{
|
||||
use CommonPeople;
|
||||
|
||||
/**
|
||||
* @var string ID to identify managed object
|
||||
*/
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonsocialnetworks.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonpeople.class.php';
|
||||
|
||||
|
||||
/**
|
||||
@ -41,6 +42,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonsocialnetworks.class.php';
|
||||
class Contact extends CommonObject
|
||||
{
|
||||
use CommonSocialNetworks;
|
||||
use CommonPeople;
|
||||
|
||||
/**
|
||||
* @var string ID to identify managed object
|
||||
|
||||
@ -854,70 +854,6 @@ abstract class CommonObject
|
||||
return $objref.(isset($hookmanager->resArray['objref']) ? $hookmanager->resArray['objref'] : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return full name (civility+' '+name+' '+lastname)
|
||||
*
|
||||
* @param Translate $langs Language object for translation of civility (used only if option is 1)
|
||||
* @param int $option 0=No option, 1=Add civility
|
||||
* @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname, 4=Lastname, 5=Lastname if defined else firstname
|
||||
* @param int $maxlen Maximum length
|
||||
* @return string String with full name
|
||||
*/
|
||||
public function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0)
|
||||
{
|
||||
//print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."<br>\n";
|
||||
$lastname = $this->lastname;
|
||||
$firstname = $this->firstname;
|
||||
if (empty($lastname)) {
|
||||
$lastname = (isset($this->lastname) ? $this->lastname : (isset($this->name) ? $this->name : (isset($this->nom) ? $this->nom : (isset($this->societe) ? $this->societe : (isset($this->company) ? $this->company : '')))));
|
||||
}
|
||||
|
||||
$ret = '';
|
||||
if (!empty($option) && !empty($this->civility_code)) {
|
||||
if ($langs->transnoentitiesnoconv("Civility".$this->civility_code) != "Civility".$this->civility_code) {
|
||||
$ret .= $langs->transnoentitiesnoconv("Civility".$this->civility_code).' ';
|
||||
} else {
|
||||
$ret .= $this->civility_code.' ';
|
||||
}
|
||||
}
|
||||
|
||||
$ret .= dolGetFirstLastname($firstname, $lastname, $nameorder);
|
||||
|
||||
return dol_trunc($ret, $maxlen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to upper or ucwords/lower if needed
|
||||
*
|
||||
* @return void;
|
||||
*/
|
||||
public function setUpperOrLowerCase()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) {
|
||||
$this->lastname = dol_ucwords(dol_strtolower($this->lastname));
|
||||
$this->firstname = dol_ucwords(dol_strtolower($this->firstname));
|
||||
$this->name = dol_ucwords(dol_strtolower($this->name));
|
||||
$this->name_alias = isset($this->name_alias)?dol_ucwords(dol_strtolower($this->name_alias)):'';
|
||||
}
|
||||
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) {
|
||||
$this->lastname = dol_strtoupper($this->lastname);
|
||||
$this->name = dol_strtoupper($this->name);
|
||||
$this->name_alias = dol_strtoupper($this->name_alias);
|
||||
}
|
||||
if (!empty($conf->global->MAIN_ALL_TOWN_TO_UPPER)) {
|
||||
$this->address = dol_strtoupper($this->address);
|
||||
$this->town = dol_strtoupper($this->town);
|
||||
}
|
||||
if (isset($this->email)) {
|
||||
$this->email = dol_strtolower($this->email);
|
||||
}
|
||||
if (isset($this->personal_email)) {
|
||||
$this->personal_email = dol_strtolower($this->personal_email);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return full address of contact
|
||||
*
|
||||
@ -949,180 +885,6 @@ abstract class CommonObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return full address for banner
|
||||
*
|
||||
* @param string $htmlkey HTML id to make banner content unique
|
||||
* @param Object $object Object (thirdparty, thirdparty of contact for contact, null for a member)
|
||||
* @return string Full address string
|
||||
*/
|
||||
public function getBannerAddress($htmlkey, $object)
|
||||
{
|
||||
global $conf, $langs, $form, $extralanguages;
|
||||
|
||||
$countriesusingstate = array('AU', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS
|
||||
|
||||
$contactid = 0;
|
||||
$thirdpartyid = 0;
|
||||
$elementforaltlanguage = $this->element;
|
||||
if ($this->element == 'societe') {
|
||||
$thirdpartyid = $this->id;
|
||||
}
|
||||
if ($this->element == 'contact') {
|
||||
$contactid = $this->id;
|
||||
$thirdpartyid = empty($this->fk_soc) ? 0 : $this->fk_soc;
|
||||
}
|
||||
if ($this->element == 'user') {
|
||||
$contactid = $this->contact_id;
|
||||
$thirdpartyid = empty($object->fk_soc) ? 0 : $object->fk_soc;
|
||||
}
|
||||
|
||||
$out = '';
|
||||
|
||||
$outdone = 0;
|
||||
$coords = $this->getFullAddress(1, ', ', (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) ? $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT : 0));
|
||||
if ($coords) {
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
// Add picto with tooltip on map
|
||||
$namecoords = '';
|
||||
if ($this->element == 'contact' && !empty($conf->global->MAIN_SHOW_COMPANY_NAME_IN_BANNER_ADDRESS)) {
|
||||
$namecoords .= $object->name.'<br>';
|
||||
}
|
||||
$namecoords .= $this->getFullName($langs, 1).'<br>'.$coords;
|
||||
// hideonsmatphone because copyToClipboard call jquery dialog that does not work with jmobile
|
||||
$out .= '<a href="#" class="hideonsmartphone" onclick="return copyToClipboard(\''.dol_escape_js($namecoords).'\',\''.dol_escape_js($langs->trans("HelpCopyToClipboard")).'\');">';
|
||||
$out .= img_picto($langs->trans("Address"), 'map-marker-alt');
|
||||
$out .= '</a> ';
|
||||
}
|
||||
$address = dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', ');
|
||||
if ($address) {
|
||||
$out .= $address;
|
||||
$outdone++;
|
||||
}
|
||||
$outdone++;
|
||||
|
||||
// List of extra languages
|
||||
$arrayoflangcode = array();
|
||||
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) {
|
||||
$arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
|
||||
}
|
||||
|
||||
if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
|
||||
if (!is_object($extralanguages)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/extralanguages.class.php';
|
||||
$extralanguages = new ExtraLanguages($this->db);
|
||||
}
|
||||
$extralanguages->fetch_name_extralanguages($elementforaltlanguage);
|
||||
|
||||
if (!empty($extralanguages->attributes[$elementforaltlanguage]['address']) || !empty($extralanguages->attributes[$elementforaltlanguage]['town'])) {
|
||||
$out .= "<!-- alternatelanguage for '".$elementforaltlanguage."' set to fields '".join(',', $extralanguages->attributes[$elementforaltlanguage])."' -->\n";
|
||||
$this->fetchValuesForExtraLanguages();
|
||||
if (!is_object($form)) {
|
||||
$form = new Form($this->db);
|
||||
}
|
||||
$htmltext = '';
|
||||
// If there is extra languages
|
||||
foreach ($arrayoflangcode as $extralangcode) {
|
||||
$s = picto_from_langcode($extralangcode, 'class="pictoforlang paddingright"');
|
||||
// This also call dol_format_address()
|
||||
$coords = $this->getFullAddress(1, ', ', $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT, $extralangcode);
|
||||
$htmltext .= $s.dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', ');
|
||||
}
|
||||
$out .= $form->textwithpicto('', $htmltext, -1, 'language', 'opacitymedium paddingleft');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress
|
||||
if (!in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)
|
||||
&& empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) {
|
||||
if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) {
|
||||
$out .= ($outdone ? ' - ' : '').$this->region.' - '.$this->state;
|
||||
} else {
|
||||
$out .= ($outdone ? ' - ' : '').$this->state;
|
||||
}
|
||||
$outdone++;
|
||||
}
|
||||
|
||||
if ($outdone) {
|
||||
$out = '<div class="address inline-block">'.$out.'</div>';
|
||||
}
|
||||
|
||||
if (!empty($this->phone) || !empty($this->phone_pro) || !empty($this->phone_mobile) || !empty($this->phone_perso) || !empty($this->fax) || !empty($this->office_phone) || !empty($this->user_mobile) || !empty($this->office_fax)) {
|
||||
$out .= ($outdone ? '<br>' : '');
|
||||
}
|
||||
if (!empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone
|
||||
$out .= dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->phone_pro)) {
|
||||
$out .= dol_print_phone($this->phone_pro, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->phone_mobile)) {
|
||||
$out .= dol_print_phone($this->phone_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->phone_perso)) {
|
||||
$out .= dol_print_phone($this->phone_perso, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePerso"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->office_phone)) {
|
||||
$out .= dol_print_phone($this->office_phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->user_mobile)) {
|
||||
$out .= dol_print_phone($this->user_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->fax)) {
|
||||
$out .= dol_print_phone($this->fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->office_fax)) {
|
||||
$out .= dol_print_phone($this->office_fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax"));
|
||||
$outdone++;
|
||||
}
|
||||
|
||||
if ($out) {
|
||||
$out .= '<div style="clear: both;"></div>';
|
||||
}
|
||||
$outdone = 0;
|
||||
if (!empty($this->email)) {
|
||||
$out .= dol_print_email($this->email, $this->id, $object->id, 'AC_EMAIL', 0, 0, 1);
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->url)) {
|
||||
//$out.=dol_print_url($this->url,'_goout',0,1);//steve changed to blank
|
||||
$out .= dol_print_url($this->url, '_blank', 0, 1);
|
||||
$outdone++;
|
||||
}
|
||||
|
||||
if (isModEnabled('socialnetworks')) {
|
||||
$outsocialnetwork = '';
|
||||
|
||||
if (!empty($this->socialnetworks) && is_array($this->socialnetworks) && count($this->socialnetworks) > 0) {
|
||||
$socialnetworksdict = getArrayOfSocialNetworks();
|
||||
foreach ($this->socialnetworks as $key => $value) {
|
||||
if ($value) {
|
||||
$outsocialnetwork .= dol_print_socialnetworks($value, $this->id, $object->id, $key, $socialnetworksdict);
|
||||
}
|
||||
$outdone++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($outsocialnetwork) {
|
||||
$out .= '<div style="clear: both;">'.$outsocialnetwork.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($out) {
|
||||
return '<!-- BEGIN part to show address block -->'."\n".$out.'<!-- END Part to show address block -->'."\n";
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the link of last main doc file for direct public download.
|
||||
*
|
||||
|
||||
267
htdocs/core/class/commonpeople.class.php
Normal file
267
htdocs/core/class/commonpeople.class.php
Normal file
@ -0,0 +1,267 @@
|
||||
<?php
|
||||
/* Copyright (C) 2023 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/class/commonpeople.class.php
|
||||
* \ingroup core
|
||||
* \brief File of the superclass of object classes that support people
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Superclass for thirdparties, contacts, members or users
|
||||
*/
|
||||
trait CommonPeople
|
||||
{
|
||||
/**
|
||||
* Return full name (civility+' '+name+' '+lastname)
|
||||
*
|
||||
* @param Translate $langs Language object for translation of civility (used only if option is 1)
|
||||
* @param int $option 0=No option, 1=Add civility
|
||||
* @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname, 4=Lastname, 5=Lastname if defined else firstname
|
||||
* @param int $maxlen Maximum length
|
||||
* @return string String with full name
|
||||
*/
|
||||
public function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0)
|
||||
{
|
||||
//print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."<br>\n";
|
||||
$lastname = $this->lastname;
|
||||
$firstname = $this->firstname;
|
||||
if (empty($lastname)) {
|
||||
$lastname = (isset($this->lastname) ? $this->lastname : (isset($this->name) ? $this->name : (isset($this->nom) ? $this->nom : (isset($this->societe) ? $this->societe : (isset($this->company) ? $this->company : '')))));
|
||||
}
|
||||
|
||||
$ret = '';
|
||||
if (!empty($option) && !empty($this->civility_code)) {
|
||||
if ($langs->transnoentitiesnoconv("Civility".$this->civility_code) != "Civility".$this->civility_code) {
|
||||
$ret .= $langs->transnoentitiesnoconv("Civility".$this->civility_code).' ';
|
||||
} else {
|
||||
$ret .= $this->civility_code.' ';
|
||||
}
|
||||
}
|
||||
|
||||
$ret .= dolGetFirstLastname($firstname, $lastname, $nameorder);
|
||||
|
||||
return dol_trunc($ret, $maxlen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return full address for banner
|
||||
*
|
||||
* @param string $htmlkey HTML id to make banner content unique
|
||||
* @param Object $object Object (thirdparty, thirdparty of contact for contact, null for a member)
|
||||
* @return string Full address string
|
||||
*/
|
||||
public function getBannerAddress($htmlkey, $object)
|
||||
{
|
||||
global $conf, $langs, $form, $extralanguages;
|
||||
|
||||
$countriesusingstate = array('AU', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS
|
||||
|
||||
$contactid = 0;
|
||||
$thirdpartyid = 0;
|
||||
$elementforaltlanguage = $this->element;
|
||||
if ($this->element == 'societe') {
|
||||
$thirdpartyid = $this->id;
|
||||
}
|
||||
if ($this->element == 'contact') {
|
||||
$contactid = $this->id;
|
||||
$thirdpartyid = empty($this->fk_soc) ? 0 : $this->fk_soc;
|
||||
}
|
||||
if ($this->element == 'user') {
|
||||
$contactid = $this->contact_id;
|
||||
$thirdpartyid = empty($object->fk_soc) ? 0 : $object->fk_soc;
|
||||
}
|
||||
|
||||
$out = '';
|
||||
|
||||
$outdone = 0;
|
||||
$coords = $this->getFullAddress(1, ', ', (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) ? $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT : 0));
|
||||
if ($coords) {
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
// Add picto with tooltip on map
|
||||
$namecoords = '';
|
||||
if ($this->element == 'contact' && !empty($conf->global->MAIN_SHOW_COMPANY_NAME_IN_BANNER_ADDRESS)) {
|
||||
$namecoords .= $object->name.'<br>';
|
||||
}
|
||||
$namecoords .= $this->getFullName($langs, 1).'<br>'.$coords;
|
||||
// hideonsmatphone because copyToClipboard call jquery dialog that does not work with jmobile
|
||||
$out .= '<a href="#" class="hideonsmartphone" onclick="return copyToClipboard(\''.dol_escape_js($namecoords).'\',\''.dol_escape_js($langs->trans("HelpCopyToClipboard")).'\');">';
|
||||
$out .= img_picto($langs->trans("Address"), 'map-marker-alt');
|
||||
$out .= '</a> ';
|
||||
}
|
||||
$address = dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', ');
|
||||
if ($address) {
|
||||
$out .= $address;
|
||||
$outdone++;
|
||||
}
|
||||
$outdone++;
|
||||
|
||||
// List of extra languages
|
||||
$arrayoflangcode = array();
|
||||
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) {
|
||||
$arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
|
||||
}
|
||||
|
||||
if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
|
||||
if (!is_object($extralanguages)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/extralanguages.class.php';
|
||||
$extralanguages = new ExtraLanguages($this->db);
|
||||
}
|
||||
$extralanguages->fetch_name_extralanguages($elementforaltlanguage);
|
||||
|
||||
if (!empty($extralanguages->attributes[$elementforaltlanguage]['address']) || !empty($extralanguages->attributes[$elementforaltlanguage]['town'])) {
|
||||
$out .= "<!-- alternatelanguage for '".$elementforaltlanguage."' set to fields '".join(',', $extralanguages->attributes[$elementforaltlanguage])."' -->\n";
|
||||
$this->fetchValuesForExtraLanguages();
|
||||
if (!is_object($form)) {
|
||||
$form = new Form($this->db);
|
||||
}
|
||||
$htmltext = '';
|
||||
// If there is extra languages
|
||||
foreach ($arrayoflangcode as $extralangcode) {
|
||||
$s = picto_from_langcode($extralangcode, 'class="pictoforlang paddingright"');
|
||||
// This also call dol_format_address()
|
||||
$coords = $this->getFullAddress(1, ', ', $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT, $extralangcode);
|
||||
$htmltext .= $s.dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', ');
|
||||
}
|
||||
$out .= $form->textwithpicto('', $htmltext, -1, 'language', 'opacitymedium paddingleft');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress
|
||||
if (!in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)
|
||||
&& empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) {
|
||||
if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) {
|
||||
$out .= ($outdone ? ' - ' : '').$this->region.' - '.$this->state;
|
||||
} else {
|
||||
$out .= ($outdone ? ' - ' : '').$this->state;
|
||||
}
|
||||
$outdone++;
|
||||
}
|
||||
|
||||
if ($outdone) {
|
||||
$out = '<div class="address inline-block">'.$out.'</div>';
|
||||
}
|
||||
|
||||
if (!empty($this->phone) || !empty($this->phone_pro) || !empty($this->phone_mobile) || !empty($this->phone_perso) || !empty($this->fax) || !empty($this->office_phone) || !empty($this->user_mobile) || !empty($this->office_fax)) {
|
||||
$out .= ($outdone ? '<br>' : '');
|
||||
}
|
||||
if (!empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone
|
||||
$out .= dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->phone_pro)) {
|
||||
$out .= dol_print_phone($this->phone_pro, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->phone_mobile)) {
|
||||
$out .= dol_print_phone($this->phone_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->phone_perso)) {
|
||||
$out .= dol_print_phone($this->phone_perso, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePerso"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->office_phone)) {
|
||||
$out .= dol_print_phone($this->office_phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->user_mobile)) {
|
||||
$out .= dol_print_phone($this->user_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->fax)) {
|
||||
$out .= dol_print_phone($this->fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax"));
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->office_fax)) {
|
||||
$out .= dol_print_phone($this->office_fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax"));
|
||||
$outdone++;
|
||||
}
|
||||
|
||||
if ($out) {
|
||||
$out .= '<div style="clear: both;"></div>';
|
||||
}
|
||||
$outdone = 0;
|
||||
if (!empty($this->email)) {
|
||||
$out .= dol_print_email($this->email, $this->id, $object->id, 'AC_EMAIL', 0, 0, 1);
|
||||
$outdone++;
|
||||
}
|
||||
if (!empty($this->url)) {
|
||||
//$out.=dol_print_url($this->url,'_goout',0,1);//steve changed to blank
|
||||
$out .= dol_print_url($this->url, '_blank', 0, 1);
|
||||
$outdone++;
|
||||
}
|
||||
|
||||
if (isModEnabled('socialnetworks')) {
|
||||
$outsocialnetwork = '';
|
||||
|
||||
if (!empty($this->socialnetworks) && is_array($this->socialnetworks) && count($this->socialnetworks) > 0) {
|
||||
$socialnetworksdict = getArrayOfSocialNetworks();
|
||||
foreach ($this->socialnetworks as $key => $value) {
|
||||
if ($value) {
|
||||
$outsocialnetwork .= dol_print_socialnetworks($value, $this->id, $object->id, $key, $socialnetworksdict);
|
||||
}
|
||||
$outdone++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($outsocialnetwork) {
|
||||
$out .= '<div style="clear: both;">'.$outsocialnetwork.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($out) {
|
||||
return '<!-- BEGIN part to show address block -->'."\n".$out.'<!-- END Part to show address block -->'."\n";
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to upper or ucwords/lower if needed
|
||||
*
|
||||
* @return void;
|
||||
*/
|
||||
public function setUpperOrLowerCase()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) {
|
||||
$this->lastname = dol_ucwords(dol_strtolower($this->lastname));
|
||||
$this->firstname = dol_ucwords(dol_strtolower($this->firstname));
|
||||
$this->name = dol_ucwords(dol_strtolower($this->name));
|
||||
$this->name_alias = isset($this->name_alias)?dol_ucwords(dol_strtolower($this->name_alias)):'';
|
||||
}
|
||||
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) {
|
||||
$this->lastname = dol_strtoupper($this->lastname);
|
||||
$this->name = dol_strtoupper($this->name);
|
||||
$this->name_alias = dol_strtoupper($this->name_alias);
|
||||
}
|
||||
if (!empty($conf->global->MAIN_ALL_TOWN_TO_UPPER)) {
|
||||
$this->address = dol_strtoupper($this->address);
|
||||
$this->town = dol_strtoupper($this->town);
|
||||
}
|
||||
if (isset($this->email)) {
|
||||
$this->email = dol_strtolower($this->email);
|
||||
}
|
||||
if (isset($this->personal_email)) {
|
||||
$this->personal_email = dol_strtolower($this->personal_email);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -331,3 +331,56 @@ function getDefaultDatesForTransfer()
|
||||
'pastmonth' => $pastmonth
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current period of fiscal year
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param stdClass $conf Config
|
||||
* @param int $from_time [=null] Get current time or set time to find fiscal period
|
||||
* @return array Period of fiscal year : [date_start, date_end]
|
||||
*/
|
||||
function getCurrentPeriodOfFiscalYear($db, $conf, $from_time = null)
|
||||
{
|
||||
$now = dol_now();
|
||||
$now_arr = dol_getdate($now);
|
||||
if ($from_time === null) {
|
||||
$from_time = $now;
|
||||
}
|
||||
$from_db_time = $db->idate($from_time);
|
||||
|
||||
$sql = "SELECT date_start, date_end FROM ".$db->prefix()."accounting_fiscalyear";
|
||||
$sql .= " WHERE date_start <= '".$db->escape($from_db_time)."' AND date_end >= '".$db->escape($from_db_time)."'";
|
||||
$sql .= $db->order('date_start', 'DESC');
|
||||
$sql .= $db->plimit(1);
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res) > 0) {
|
||||
$obj = $db->fetch_object($res);
|
||||
|
||||
$date_start = $db->jdate($obj->date_start);
|
||||
$date_end = $db->jdate($obj->date_end);
|
||||
} else {
|
||||
$month_start = 1;
|
||||
$conf_fiscal_month_start = (int) $conf->global->SOCIETE_FISCAL_MONTH_START;
|
||||
if ($conf_fiscal_month_start >= 1 && $conf_fiscal_month_start <= 12) {
|
||||
$month_start = $conf_fiscal_month_start;
|
||||
}
|
||||
$year_start = $now_arr['year'];
|
||||
if ($conf_fiscal_month_start > $now_arr['mon']) {
|
||||
$year_start = $year_start - 1;
|
||||
}
|
||||
$year_end = $year_start + 1;
|
||||
$month_end = $month_start - 1;
|
||||
if ($month_end < 1) {
|
||||
$month_end = 12;
|
||||
$year_end--;
|
||||
}
|
||||
$date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
|
||||
$date_end = dol_get_last_day($year_end, $month_end);
|
||||
}
|
||||
|
||||
return array(
|
||||
'date_start' => $date_start,
|
||||
'date_end' => $date_end,
|
||||
);
|
||||
}
|
||||
|
||||
@ -2668,6 +2668,8 @@ function getModuleDirForApiClass($moduleobject)
|
||||
$moduledirforclass = 'fichinter';
|
||||
} elseif ($moduleobject == 'mos') {
|
||||
$moduledirforclass = 'mrp';
|
||||
} elseif ($moduleobject == 'accounting') {
|
||||
$moduledirforclass = 'accountancy';
|
||||
} elseif (in_array($moduleobject, array('products', 'expensereports', 'users', 'tickets', 'boms', 'receptions'))) {
|
||||
$moduledirforclass = preg_replace('/s$/', '', $moduleobject);
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ class modAccounting extends DolibarrModules
|
||||
$this->picto = 'accountancy';
|
||||
|
||||
// Data directories to create when module is enabled
|
||||
$this->dirs = array('/accounting/temp');
|
||||
$this->dirs = array('/accounting/temp', '/accounting/export');
|
||||
|
||||
// Config pages
|
||||
$this->config_page_url = array('accounting.php?mainmenu=accountancy&leftmenu=accountancy_admin');
|
||||
|
||||
@ -406,4 +406,15 @@ ALTER TABLE llx_projet ADD COLUMN extraparams varchar(255);
|
||||
|
||||
DELETE FROM llx_const WHERE name = 'TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST';
|
||||
|
||||
|
||||
INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('GR-ΠΡΩΤΟΧΡΟΝΙΑ', 0, 102, '', 0, 1, 1, 1);
|
||||
INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('GR-ΘΕΟΦΑΝΕΙΑ', 0, 102, '', 0, 1, 6, 1);
|
||||
INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('GR-25Η ΜΑΡΤΙΟΥ', 0, 102, '', 0, 3, 25, 1);
|
||||
INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('GR-ΠΡΩΤΟΜΑΓΙΑ', 0, 102, '', 0, 5, 1, 1);
|
||||
INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('GR-ΚΑΘΑΡΑ ΔΕΥΤΕΡΑ', 0, 102, 'ΚΑΘΑΡΑ_ΔΕΥΤΕΡΑ', 0, 0, 0, 1);
|
||||
INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('GR-ΜΕΓΑΛΗ ΠΑΡΑΣΚΕΥΗ', 0, 102, 'ΜΕΓΑΛΗ_ΠΑΡΑΣΚΕΥΗ', 0, 0, 0, 1);
|
||||
INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('GR-ΔΕΥΤΕΡΑ ΤΟΥ ΠΑΣΧΑ', 0, 102, 'ΔΕΥΤΕΡΑ_ΤΟΥ_ΠΑΣΧΑ', 0, 0, 0, 1);
|
||||
INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('GR-ΤΟΥ ΑΓΙΟΥ ΠΝΕΥΜΑΤΟΣ', 0, 102, 'ΤΟΥ_ΑΓΙΟΥ_ΠΝΕΥΜΑΤΟΣ', 0, 0, 0, 1);
|
||||
INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('GR-ΚΟΙΜΗΣΗ ΤΗΣ ΘΕΟΤΟΚΟΥ', 0, 102, '', 0, 8, 15, 1);
|
||||
INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('GR-28Η ΟΚΤΩΒΡΙΟΥ', 0, 102, '', 0, 10, 28, 1);
|
||||
INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('GR-ΧΡΙΣΤΟΥΓΕΝΝΑ', 0, 102, '', 0, 12, 25, 1);
|
||||
INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('GR-ΣΥΝΑΞΗ ΘΕΟΤΟΚΟΥ', 0, 102, '', 0, 12, 26, 1);
|
||||
|
||||
@ -219,7 +219,7 @@ class MultiCurrencies extends DolibarrApi
|
||||
|
||||
// Add default rate if defined
|
||||
if (isset($request_data['rate']) && $request_data['rate'] > 0) {
|
||||
if ($multicurrency->addRate(DolibarrApiAccess::$user, $request_data['rate']) < 0) {
|
||||
if ($multicurrency->addRate($request_data['rate']) < 0) {
|
||||
throw new RestException(500, "Error adding currency rate", array_merge(array($multicurrency->error), $multicurrency->errors));
|
||||
}
|
||||
|
||||
|
||||
@ -708,6 +708,10 @@ class Entrepot extends CommonObject
|
||||
$langs->load('stocks');
|
||||
|
||||
$datas = [];
|
||||
|
||||
$option = $params['option'] ?? '';
|
||||
$nofetch = !empty($params['nofetch']);
|
||||
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
return ['optimize' => $langs->trans("Warehouse")];
|
||||
}
|
||||
@ -719,6 +723,12 @@ class Entrepot extends CommonObject
|
||||
if (!empty($this->lieu)) {
|
||||
$datas['locationsummary'] = '<br><b>'.$langs->trans('LocationSummary').':</b> '.$this->lieu;
|
||||
}
|
||||
// show categories for this record only in ajax to not overload lists
|
||||
if (!$nofetch && isModEnabled('categorie')) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||
$form = new Form($this->db);
|
||||
$datas['categories_warehouse'] = '<br>' . $form->showCategories($this->id, Categorie::TYPE_WAREHOUSE, 1, 1);
|
||||
}
|
||||
|
||||
return $datas;
|
||||
}
|
||||
@ -752,13 +762,14 @@ class Entrepot extends CommonObject
|
||||
'id' => $this->id,
|
||||
'objecttype' => $this->element,
|
||||
'option' => $option,
|
||||
'nofetch' => 1,
|
||||
];
|
||||
$classfortooltip = 'classfortooltip';
|
||||
$dataparams = '';
|
||||
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
|
||||
$classfortooltip = 'classforajaxtooltip';
|
||||
$dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
|
||||
$label = '';
|
||||
$label = 'ToComplete';
|
||||
} else {
|
||||
$label = implode($this->getTooltipContentArray($params));
|
||||
}
|
||||
|
||||
@ -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.'/core/class/commonsocialnetworks.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonpeople.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
|
||||
|
||||
|
||||
@ -51,6 +52,7 @@ class Societe extends CommonObject
|
||||
{
|
||||
use CommonIncoterm;
|
||||
use CommonSocialNetworks;
|
||||
use CommonPeople;
|
||||
|
||||
/**
|
||||
* @var string ID of module.
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonpeople.class.php';
|
||||
|
||||
|
||||
/**
|
||||
@ -45,6 +46,8 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
|
||||
*/
|
||||
class User extends CommonObject
|
||||
{
|
||||
use CommonPeople;
|
||||
|
||||
/**
|
||||
* @var string ID to identify managed object
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user