Skip to content

Commit

Permalink
Merge branch 'develop' into sonikf-patch-pdf-rounded-corners
Browse files Browse the repository at this point in the history
  • Loading branch information
sonikf authored Sep 30, 2024
2 parents 5d59c5f + 44fdcdd commit bc837d7
Show file tree
Hide file tree
Showing 91 changed files with 933 additions and 350 deletions.
102 changes: 41 additions & 61 deletions dev/tools/phan/baseline.txt

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions dev/tools/phan/stubs/ovhsms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php
/* Copyright (C) 2024 MDW <[email protected]>
*/

namespace {
/**
* Use an OVH account to send SMS with Dolibarr
*/
class OvhSms extends \CommonObject
{
public $db;
//!< To store db handler
public $error;
//!< To return error code (or message)
public $errors = array();
//!< To return several error codes (or messages)
public $element = 'ovhsms';
//!< Id that identify managed object
public $id;
public $account;
public $socid;
public $contact_id;
public $member_id;
public $fk_project;
public $nostop;
public $expe;
public $dest;
public $message;
public $validity;
public $class;
public $deferred;
public $priority;
public $soap;
// Old API
public $conn;
// New API
public $endpoint;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
}
/**
* Logout
*
* @return void
*/
public function logout()
{
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Send SMS
*
* @return int <=0 if error, >0 if OK
*/
public function SmsSend()
{
}
/**
* Show HTML select box to select account
*
* @return void
*/
public function printListAccount()
{
}
/**
* Return list of SMSAccounts
*
* @return array
*/
public function getSmsListAccount()
{
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Return Credit
*
* @return array
*/
public function CreditLeft()
{
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Return History
*
* @return array
*/
public function SmsHistory()
{
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Return list of possible SMS senders
*
* @return array|int <0 if KO, array with list of available senders if OK
*/
public function SmsSenderList()
{
}
/**
* Call soapDebug method to output traces
*
* @return void
*/
public function soapDebug()
{
}
}
}
23 changes: 19 additions & 4 deletions htdocs/accountancy/admin/fiscalyear_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}

if ($action == 'confirm_delete' && $confirm == "yes") {
if ($action == 'confirm_delete' && $confirm == "yes" && $permissiontoadd) {
$result = $object->delete($user);
if ($result >= 0) {
header("Location: fiscalyear.php");
exit();
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'add') {
} elseif ($action == 'add' && $permissiontoadd) {
if (!GETPOST('cancel', 'alpha')) {
$error = 0;

Expand Down Expand Up @@ -144,7 +144,7 @@
header("Location: ./fiscalyear.php");
exit();
}
} elseif ($action == 'update') {
} elseif ($action == 'update' && $permissiontoadd) {
// Update record
if (!GETPOST('cancel', 'alpha')) {
$result = $object->fetch($id);
Expand All @@ -166,8 +166,19 @@
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit();
}
}
} elseif ($action == 'reopen' && $permissiontoadd && getDolGlobalString('ACCOUNTING_CAN_REOPEN_CLOSED_PERIOD')) {
$result = $object->fetch($id);

$object->status = GETPOST('status', 'int');

Check warning on line 172 in htdocs/accountancy/admin/fiscalyear_card.php

View workflow job for this annotation

GitHub Actions / phan / Run phan

fiscalyear_card.php: PhanTypeMismatchProperty: Assigning GETPOST('status', 'int') of type array|string to property but \Fiscalyear-&gt;status is int

Check failure on line 172 in htdocs/accountancy/admin/fiscalyear_card.php

View workflow job for this annotation

GitHub Actions / phpstan / php-stan (8.2)

Property Fiscalyear::$status (int) does not accept array|string.
$result = $object->update($user);

if ($result > 0) {
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit();
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}


/*
Expand Down Expand Up @@ -364,6 +375,10 @@
if ($user->hasRight('accounting', 'fiscalyear', 'write')) {
print '<div class="tabsAction">';

if (getDolGlobalString('ACCOUNTING_CAN_REOPEN_CLOSED_PERIOD') && $object->status == $object::STATUS_CLOSED) {
print dolGetButtonAction($langs->trans("ReOpen"), '', 'reopen', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken(), 'reopen', $permissiontoadd);
}

print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$id.'">'.$langs->trans('Modify').'</a>';

//print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
Expand Down
7 changes: 2 additions & 5 deletions htdocs/accountancy/bookkeeping/balance.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
accessforbidden();
}


/*
* Action
*/
Expand Down Expand Up @@ -169,10 +170,6 @@
$filter['t.doc_date<='] = $search_date_end;
$param .= '&date_endmonth=' . GETPOSTINT('date_endmonth') . '&date_endday=' . GETPOSTINT('date_endday') . '&date_endyear=' . GETPOSTINT('date_endyear');
}
if (!empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date;
$param .= '&doc_datemonth=' . GETPOSTINT('doc_datemonth') . '&doc_dateday=' . GETPOSTINT('doc_dateday') . '&doc_dateyear=' . GETPOSTINT('doc_dateyear');
}
if (!empty($search_accountancy_code_start)) {
if ($type == 'sub') {
$filter['t.subledger_account>='] = $search_accountancy_code_start;
Expand Down Expand Up @@ -207,7 +204,7 @@
}
}

if ($action == 'export_csv') {
if ($action == 'export_csv' && $user->hasRight('accounting', 'mouvements', 'lire')) {
$sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV');

$filename = 'balance';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/class/bookkeeping.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2536,7 +2536,7 @@ public function loadFiscalPeriods($force = false, $mode = 'active')
}

/**
* Get list of fiscal period
* Get list of fiscal period ordered by start date.
*
* @param string $filter Filter
* @return array<array{id:int,label:string,date_start:string,date_end:string,status:int}>|int Return integer <0 if KO, Fiscal periods : [[id, date_start, date_end, label], ...]
Expand Down
55 changes: 38 additions & 17 deletions htdocs/accountancy/closure/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,57 @@
setEventMessages($object->error, $object->errors, 'errors');
}

// Define the arrays of fiscal periods
$active_fiscal_periods = array();
$first_active_fiscal_period = null;
$last_fiscal_period = null;
$current_fiscal_period = null;
$next_fiscal_period = null;
$next_active_fiscal_period = null;
if (is_array($fiscal_periods)) {
foreach ($fiscal_periods as $fiscal_period) {
if (empty($fiscal_period['status'])) {
foreach ($fiscal_periods as $fiscal_period) { // List of fiscal periods sorted by date start
if (empty($first_active_fiscal_period) && empty($fiscal_period['status'])) {
$first_active_fiscal_period = $fiscal_period;
}
if (empty($fiscal_period['status'])) { // if not closed
$active_fiscal_periods[] = $fiscal_period;
}
if (isset($current_fiscal_period)) {
if (isset($current_fiscal_period)) { // If we already reach then current fiscal period, then this one is the next one just after
if (!isset($next_fiscal_period)) {
$next_fiscal_period = $fiscal_period;
}
if (!isset($next_active_fiscal_period) && empty($fiscal_period['status'])) {
$next_active_fiscal_period = $fiscal_period;
}
} else {
} else { // If we did not found the current fiscal period
if ($fiscal_period_id == $fiscal_period['id'] || (empty($fiscal_period_id) && $fiscal_period['date_start'] <= $now && $now <= $fiscal_period['date_end'])) {
$current_fiscal_period = $fiscal_period;
} else {
$last_fiscal_period = $fiscal_period;
$last_fiscal_period = $fiscal_period; // $last_fiscal_period is in fact $previous_fiscal_period
}
}
}
}

// If a current fiscal period open with an end and start date was not found, we autoselect the first one that is open and has a start and end date defined
if (empty($current_fiscal_period) && !empty($first_active_fiscal_period)) {
$current_fiscal_period = $first_active_fiscal_period;
$last_fiscal_period = null;
$foundcurrent = false;
foreach ($fiscal_periods as $fiscal_period) { // List of fiscal periods sorted by date start
if ($foundcurrent) {
$next_fiscal_period = $fiscal_period;
break;
}
if ($fiscal_period['id'] == $current_fiscal_period['id']) {
$foundcurrent = true;
}
if (!$foundcurrent) {
$last_fiscal_period = $fiscal_period;
}
}
}

$accounting_groups_used_for_balance_sheet_account = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT'))), 'strlen');
$accounting_groups_used_for_income_statement = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT'))), 'strlen');

Expand All @@ -103,8 +127,8 @@
}

if (empty($reshook)) {
if (isset($current_fiscal_period) && $user->hasRight('accounting', 'fiscalyear', 'write')) {
if ($action == 'confirm_step_1' && $confirm == "yes") {
if (isset($current_fiscal_period)) {
if ($action == 'confirm_step_1' && $confirm == "yes" && $user->hasRight('accounting', 'fiscalyear', 'write')) {
$date_start = dol_mktime(0, 0, 0, GETPOSTINT('date_startmonth'), GETPOSTINT('date_startday'), GETPOSTINT('date_startyear'));
$date_end = dol_mktime(23, 59, 59, GETPOSTINT('date_endmonth'), GETPOSTINT('date_endday'), GETPOSTINT('date_endyear'));

Expand All @@ -119,7 +143,7 @@
setEventMessages($object->error, $object->errors, 'errors');
$action = '';
}
} elseif ($action == 'confirm_step_2' && $confirm == "yes") {
} elseif ($action == 'confirm_step_2' && $confirm == "yes" && $user->hasRight('accounting', 'fiscalyear', 'write')) {
$new_fiscal_period_id = GETPOSTINT('new_fiscal_period_id');
$separate_auxiliary_account = GETPOST('separate_auxiliary_account', 'aZ09');
$generate_bookkeeping_records = GETPOST('generate_bookkeeping_records', 'aZ09');
Expand All @@ -128,11 +152,10 @@
if ($generate_bookkeeping_records) {
if (!getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT')) {
$error++;
setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors');
}
if (!getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT')) {
setEventMessages($langs->trans("ErrorAccountingClosureSetupNotComplete"), null, 'errors');
} elseif (!getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT')) {
$error++;
setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors');
setEventMessages($langs->trans("ErrorAccountingClosureSetupNotComplete"), null, 'errors');
}
}

Expand All @@ -147,7 +170,7 @@
exit;
}
}
} elseif ($action == 'confirm_step_3' && $confirm == "yes") {
} elseif ($action == 'confirm_step_3' && $confirm == "yes" && $user->hasRight('accounting', 'fiscalyear', 'write')) {
$inventory_journal_id = GETPOSTINT('inventory_journal_id');
$new_fiscal_period_id = GETPOSTINT('new_fiscal_period_id');
$date_start = dol_mktime(0, 0, 0, GETPOSTINT('date_startmonth'), GETPOSTINT('date_startday'), GETPOSTINT('date_startyear'));
Expand Down Expand Up @@ -316,9 +339,7 @@

if (empty($current_fiscal_period)) {
print $langs->trans('ErrorNoFiscalPeriodActiveFound', $langs->transnoentitiesnoconv("Accounting"), $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("FiscalPeriod"));
}

if (isset($current_fiscal_period)) {
} else {
// Step 1
$head = array();
$head[0][0] = DOL_URL_ROOT . '/accountancy/closure/index.php?fiscal_period_id=' . $current_fiscal_period['id'];
Expand Down Expand Up @@ -384,7 +405,7 @@
if (empty($count_by_month['total']) && empty($current_fiscal_period['status'])) {
$button = '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=step_2&fiscal_period_id=' . $current_fiscal_period['id'] . '">' . $langs->trans("AccountancyClosureClose") . '</a>';
} else {
$button = '<a class="butActionRefused classfortooltip" href="#">' . $langs->trans("AccountancyClosureClose") . '</a>';
$button = '<a class="butActionRefused classfortooltip" href="#" title="This fiscal period already has the status Closed. Feature disabled.">' . $langs->trans("AccountancyClosureClose") . '</a>';
}
print_barre_liste('', '', '', '', '', '', '', -1, '', '', 0, $button, '', 0, 1, 0);

Expand Down
9 changes: 8 additions & 1 deletion htdocs/accountancy/journal/sellsjournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,14 @@
if (array_key_exists($tax_id, $vatdata_cache)) {
$vatdata = $vatdata_cache[$tax_id];
} else {
$vatdata = getTaxesFromId($tax_id, $mysoc, $mysoc, 0);
if (getDolGlobalString('SERVICE_ARE_ECOMMERCE_200238EC')) {
$buyer = new Societe($db);
$buyer->fetch($obj->socid);
} else {
$buyer = null; // We don't need the buyer in this case
}
$seller = $mysoc;
$vatdata = getTaxesFromId($tax_id, $buyer, $seller, 0);
$vatdata_cache[$tax_id] = $vatdata;
}
$compta_tva = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
Expand Down
6 changes: 3 additions & 3 deletions htdocs/admin/modulehelp.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,6 @@

$text .= '<br><span class="opacitymedium">'.$langs->trans("IdModule").':</span> '.$objMod->numero;

$text .= '<br><span class="opacitymedium">'.$langs->trans("Version").':</span> '.$version;

$textexternal = '';
if ($objMod->isCoreOrExternalModule() == 'external') {
$tmpdirofmoduletoshow = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', (string) $dirofmodule);
Expand Down Expand Up @@ -381,8 +379,10 @@
} elseif (!empty($objMod->enabled_bydefault)) {
$text .= ' &nbsp; <span class="italic opacitymedium">('.$langs->trans("EnabledByDefaultAtInstall").')</span>';
}
$text .= '<br>';
}

$text .= '<br><span class="opacitymedium">'.$langs->trans("Version").':</span> '.$version;

$text .= '<br>';

$moduledesclong = $objMod->getDescLong();
Expand Down
2 changes: 1 addition & 1 deletion htdocs/admin/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@

if ($action == 'checklastversion') {
if ($foundoneexternalmodulewithupdate) {
setEventMessages($langs->trans("ModuleUpdateAvailable"), null, 'warnings');
setEventMessages($langs->trans("ModuleUpdateAvailable"), null, 'warnings', '', 0, 1);
} else {
setEventMessages($langs->trans("NoExternalModuleWithUpdate"), null, 'mesgs');
}
Expand Down
Loading

0 comments on commit bc837d7

Please sign in to comment.