Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur
2023-03-04 15:25:58 +01:00
24 changed files with 244 additions and 141 deletions

View File

@@ -646,7 +646,7 @@ class AccountancyCategory // extends CommonObject
}
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
//if (in_array($this->db->type, array('mysql', 'mysqli'))) $sql.=' USE INDEX idx_accounting_bookkeeping_doc_date';
$sql .= " WHERE t.entity = ".$conf->entity;
$sql .= " WHERE t.entity = ".((int) $conf->entity);
if (is_array($cpt)) {
$sql .= " AND t.numero_compte IN (".$this->db->sanitize($listofaccount, 1).")";
} else {

View File

@@ -128,8 +128,8 @@ if ($action == 'validatehistory') {
// Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind
// Customer Invoice lines (must be same request than into page list.php for manual binding)
$sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype, f.fk_facture_source,";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype, f.situation_cycle_ref, f.fk_facture_source,";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.situation_percent, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,";
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
$sql .= " ppe.accountancy_code_sell as code_sell, ppe.accountancy_code_sell_intra as code_sell_intra, ppe.accountancy_code_sell_export as code_sell_export,";
@@ -312,6 +312,10 @@ print '<span class="opacitymedium">'.$langs->trans("DescVentilCustomer").'</span
print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'<br>';
print '</span><br>';
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
print info_admin($langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices"));
print "<br>";
}
$y = $year_current;
@@ -386,6 +390,11 @@ if ($resql) {
$num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) {
// TODO When INVOICE_USE_SITUATION = 1, values here are wrong. There is no compensation on bad stored amounts
//$situation_ratio = 1;
//if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
//}
print '<tr class="oddeven">';
print '<td>';
if ($row[0] == 'tobind') {
@@ -519,6 +528,11 @@ if ($resql) {
$num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) {
// TODO When INVOICE_USE_SITUATION = 1, values here are wrong. There is no compensation on bad stored amounts
//$situation_ratio = 1;
//if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
//}
print '<tr class="oddeven">';
print '<td>';
if ($row[0] == 'tobind') {
@@ -630,7 +644,6 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa
print "</table>\n";
print '</div>';
if (isModEnabled('margin')) {
print "<br>\n";
print '<div class="div-table-responsive-no-min">';
@@ -644,22 +657,41 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT '".$db->escape($langs->trans("Vide"))."' AS marge,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql("MONTH(f.datef)=".$j,
" (".$db->ifsql("fd.total_ht < 0",
" (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))",
" (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))").")",
0).") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
}
$sql .= " SUM(".$db->ifsql("fd.total_ht < 0",
" (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))",
" (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))").") as total";
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
// With old situation invoice setup
$sql = "SELECT '".$db->escape($langs->trans("Vide"))."' AS marge,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql("MONTH(f.datef)=".$j,
" (".$db->ifsql("fd.total_ht < 0",
" (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))", // TODO This is bugged, we must use the percent for the invoice and fd.situation_percent is cumulated percent !
" (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))").")",
0).") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
}
$sql .= " SUM(".$db->ifsql("fd.total_ht < 0",
" (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))", // TODO This is bugged, we must use the percent for the invoice and fd.situation_percent is cumulated percent !
" (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))").") as total";
} else {
$sql = "SELECT '".$db->escape($langs->trans("Vide"))."' AS marge,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql("MONTH(f.datef)=".$j,
" (".$db->ifsql("fd.total_ht < 0",
" (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty)))",
" (fd.total_ht - (fd.buy_price_ht * fd.qty))").")",
0).") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
}
$sql .= " SUM(".$db->ifsql("fd.total_ht < 0",
" (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty)))",
" (fd.total_ht - (fd.buy_price_ht * fd.qty))").") as total";
}
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'";

View File

@@ -189,8 +189,8 @@ print '<script type="text/javascript">
/*
* Customer Invoice lines
*/
$sql = "SELECT f.rowid as facid, f.ref as ref, f.type as ftype, f.datef, f.ref_client,";
$sql .= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,";
$sql = "SELECT f.rowid as facid, f.ref as ref, f.type as ftype, f.situation_cycle_ref, f.datef, f.ref_client,";
$sql .= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc, fd.situation_percent,";
$sql .= " s.rowid as socid, s.nom as name, s.code_client,";
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
$sql .= " spe.accountancy_code_customer as code_compta_client,";
@@ -502,8 +502,33 @@ if ($result) {
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
print '</td>';
print '<td class="right nowraponall amount">'.price($objp->total_ht).'</td>';
// Amount
print '<td class="right nowraponall amount">';
// Create a compensation rate for old situation invoice feature.
$situation_ratio = 1;
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
if ($objp->situation_cycle_ref) {
// Avoid divide by 0
if ($objp->situation_percent == 0) {
$situation_ratio = 0;
} else {
$line = new FactureLigne($db);
$line->fetch($objp->rowid);
// Situation invoices handling
$prev_progress = $line->get_prev_progress($objp->facid);
$situation_ratio = ($objp->situation_percent - $prev_progress) / $objp->situation_percent;
}
}
print price($objp->total_ht * $situation_ratio);
} else {
print price($objp->total_ht);
}
print '</td>';
// Vat rate
print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
// Thirdparty

View File

@@ -228,8 +228,8 @@ if (empty($chartaccountcode)) {
}
// Customer Invoice lines
$sql = "SELECT f.rowid as facid, f.ref, f.datef, f.type as ftype, f.fk_facture_source,";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql = "SELECT f.rowid as facid, f.ref, f.datef, f.type as ftype, f.situation_cycle_ref, f.fk_facture_source,";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.situation_percent, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,";
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
$sql .= " ppe.accountancy_code_sell as code_sell, ppe.accountancy_code_sell_intra as code_sell_intra, ppe.accountancy_code_sell_export as code_sell_export,";
@@ -655,8 +655,30 @@ if ($result) {
print $form->textwithtooltip(dol_trunc($text, $trunclength), $facture_static_det->desc);
print '</td>';
// Amount
print '<td class="right nowraponall amount">';
print price($objp->total_ht);
// Create a compensation rate for old situation invoice feature.
$situation_ratio = 1;
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
if ($objp->situation_cycle_ref) {
// Avoid divide by 0
if ($objp->situation_percent == 0) {
$situation_ratio = 0;
} else {
$line = new FactureLigne($db);
$line->fetch($objp->rowid);
// Situation invoices handling
$prev_progress = $line->get_prev_progress($objp->facid);
$situation_ratio = ($objp->situation_percent - $prev_progress) / $objp->situation_percent;
}
}
print price($objp->total_ht * $situation_ratio);
} else {
print price($objp->total_ht);
}
print '</td>';
// Vat rate

View File

@@ -83,12 +83,7 @@ $help_url = 'EN:Module_Double_Entry_Accounting#Setup';
llxHeader('', $langs->trans("AccountancyArea"), $help_url);
if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_SITUATION == 1) {
print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
print '<span class="opacitymedium">'.$langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices")."</span>\n";
print "<br>";
} elseif (isModEnabled('accounting')) {
if (isModEnabled('accounting')) {
$step = 0;
$resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)

View File

@@ -106,7 +106,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
}
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty,";
$sql = "SELECT f.rowid, f.ref, f.type, f.situation_cycle_ref, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code, fd.info_bits,";
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,";
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
@@ -206,21 +206,23 @@ if ($result) {
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
}
if ($obj->type == Facture::TYPE_SITUATION) {
// Avoid divide by 0
if ($obj->situation_percent == 0) {
$situation_ratio = 0;
} else {
$line = new FactureLigne($db);
$line->fetch($obj->fdid);
// Create a compensation rate.
$situation_ratio = 1;
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
if ($obj->situation_cycle_ref) {
// Avoid divide by 0
if ($obj->situation_percent == 0) {
$situation_ratio = 0;
} else {
$line = new FactureLigne($db);
$line->fetch($obj->fdid);
// Situation invoices handling
$prev_progress = $line->get_prev_progress($obj->rowid);
// Situation invoices handling
$prev_progress = $line->get_prev_progress($obj->rowid);
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
}
}
} else {
$situation_ratio = 1;
}
// Invoice lines

View File

@@ -35,8 +35,6 @@ include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectorfilter.class
include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectoraction.class.php';
include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php';
// use Webklex\PHPIMAP;
require DOL_DOCUMENT_ROOT.'/includes/webklex/php-imap/vendor/autoload.php';
use Webklex\PHPIMAP\ClientManager;
use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
use Webklex\PHPIMAP\Exceptions\InvalidWhereQueryCriteriaException;
@@ -403,6 +401,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($action == 'scan') {
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
require_once DOL_DOCUMENT_ROOT.'/includes/webklex/php-imap/vendor/autoload.php';
if ($object->acces_type == 1) {
// Mode OAUth2 with PHP-IMAP
require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array
@@ -448,8 +448,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// We have to save the token because Google give it only once
$refreshtoken = $tokenobj->getRefreshToken();
//var_dump($tokenobj);
$tokenobj = $apiService->refreshAccessToken($tokenobj);
try {
$tokenobj = $apiService->refreshAccessToken($tokenobj);
} catch (Exception $e) {
throw new Exception("Failed to refresh access token: ".$e->getMessage());
}
$tokenobj->setRefreshToken($refreshtoken);
$storage->storeAccessToken($OAUTH_SERVICENAME, $tokenobj);
@@ -496,6 +501,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
'authentication' => "login",
]);
}
if (!$error) {
try {
// To emulate the command connect, you can run
@@ -569,7 +575,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
}
$morehtml = $form->textwithpicto($langs->trans("NbOfEmailsInInbox"), 'connect string '.$connectstringserver).': '.($morehtml ? $morehtml : '?');
$morehtml = $form->textwithpicto($langs->trans("NbOfEmailsInInbox"), 'Connect string = '.$connectstringserver.'<br>Option MAIN_IMAP_USE_PHPIMAP = '.getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')).': '.($morehtml ? $morehtml : '?');
$morehtml .= '<a class="flat paddingleft marginleftonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=scan&token='.newToken().'">'.img_picto('', 'refresh', 'class="paddingrightonly"').$langs->trans("Refresh").'</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref.'<div class="refidno">'.$morehtml.'</div>', '', 0, '', '', 0, '');

View File

@@ -629,7 +629,7 @@ if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) { // Hidden conf
Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
);
if (!empty($conf->global->INVOICE_USE_SITUATION)) {
if (getDolGlobalInt('INVOICE_USE_SITUATION')) {
$listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
}

View File

@@ -176,7 +176,7 @@ if ($elemid && $action == 'addintocategory' &&
($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) ||
($type == Categorie::TYPE_TICKET && $user->rights->ticket->write) ||
($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) ||
($type == Categorie::TYPE_MEMBER && $user->rights->projet->creer) ||
($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) ||
($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) ||
($type == Categorie::TYPE_USER && $user->rights->user->user->creer) ||
($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer)

View File

@@ -1469,7 +1469,7 @@ if ($action == 'create') {
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#projectid").change(function () {
var url = "'.DOL_URL_ROOT.'/projet/ajax/projects.php?mode=gettasks&socid="+$("#projectid").val()+"&projectid="+$("#projectid").val();
var url = "'.DOL_URL_ROOT.'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
console.log("Call url to get new list of tasks: "+url);
$.get(url, function(data) {
console.log(data);

View File

@@ -415,7 +415,7 @@ if ($usergroup > 0) {
}
$sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,";
$sql .= " a.id, a.code, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,";
$sql .= ' a.fk_user_author,a.fk_user_action,';
$sql .= " a.fk_user_author, a.fk_user_action,";
$sql .= " a.fk_contact, a.note, a.percent as percent,";
$sql .= " a.fk_element, a.elementtype, a.datec, a.tms as datem,";
$sql .= " c.code as type_code, c.libelle as type_label, c.color as type_color, c.type as type_type, c.picto as type_picto,";
@@ -933,6 +933,7 @@ while ($i < $imaxinloop) {
$actionstatic->note_private = dol_htmlentitiesbr($obj->note);
$actionstatic->datep = $db->jdate($obj->dp);
$actionstatic->percentage = $obj->percent;
$actionstatic->authorid = $obj->fk_user_author;
// Initialize $this->userassigned && this->socpeopleassigned array && this->userownerid
// but only if we need it

View File

@@ -246,13 +246,12 @@ class PropaleStats extends Stats
global $user;
$sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg";
$sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product";
$sql .= " FROM ".$this->from." INNER JOIN ".$this->from_line." ON p.rowid = tl.fk_propal INNER JOIN ".MAIN_DB_PREFIX."product as product ON tl.fk_product = product.rowid";
if (empty($user->rights->societe->client->voir) && !$user->socid) {
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
$sql .= " WHERE ".$this->where;
$sql .= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid";
$sql .= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'";
$sql .= " GROUP BY product.ref";
$sql .= $this->db->order('nb', 'DESC');

View File

@@ -6501,9 +6501,9 @@ class FactureLigne extends CommonInvoiceLine
* Returns situation_percent of the previous line.
* Warning: If invoice is a replacement invoice, this->fk_prev_id is id of the replaced line.
*
* @param int $invoiceid Invoice id
* @param int $invoiceid Invoice id
* @param bool $include_credit_note Include credit note or not
* @return int >= 0
* @return int >= 0
*/
public function get_prev_progress($invoiceid, $include_credit_note = true)
{

View File

@@ -4147,7 +4147,7 @@ class Form
public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '', $deposit_percent = -1)
{
// phpcs:enable
print $this->getSelectConditionsPaiements($selected, $htmlname, $filtertype, $addempty, $noinfoadmin, $morecss, $deposit_percent = -1);
print $this->getSelectConditionsPaiements($selected, $htmlname, $filtertype, $addempty, $noinfoadmin, $morecss, $deposit_percent);
}
@@ -8913,8 +8913,7 @@ class Form
'perms'=>1,
'label'=>'LinkToContract',
'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht
FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."contrat as t, ".$this->db->prefix()."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier'
),
FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."contrat as t, ".$this->db->prefix()."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier'),
'fichinter'=>array(
'enabled'=>isModEnabled('ficheinter'),
'perms'=>1,
@@ -8947,6 +8946,12 @@ class Form
);
}
if ($object->table_element == 'commande_fournisseur') {
$possiblelinks['mo']['sql'] = "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.rowid, '0' as total_ht FROM ".$this->db->prefix()."societe as s INNER JOIN ".$this->db->prefix().'mrp_mo as t ON t.fk_soc = s.rowid WHERE t.entity IN ('.getEntity('mo').')';
} elseif ($object->table_element == 'mrp_mo') {
$possiblelinks['order_supplier']['sql'] = "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix().'commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.entity IN ('.getEntity('commande_fournisseur').')';
}
if (!empty($listofidcompanytoscan)) { // If empty, we don't have criteria to scan the object we can link to
// Can complete the possiblelink array
$hookmanager->initHooks(array('commonobject'));

View File

@@ -1683,7 +1683,7 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef
// Multi journal
$sql = "SELECT rowid, code, label, nature";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql .= " WHERE entity = ".$conf->entity;
$sql .= " WHERE entity = ".((int) $conf->entity);
$sql .= " AND active = 1";
$sql .= " ORDER BY nature ASC, label DESC";
@@ -1734,11 +1734,12 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef
$langs->load('accountancy');
$journallabel = '';
if ($objp->label) {
$journallabelwithoutspan = $langs->transnoentities($objp->label);
$journallabel = '<span class="opacitymedium">('.$langs->transnoentities($objp->label).')</span>'; // Label of bank account in llx_accounting_journal
}
$key = $langs->trans("AccountingJournalType".strtoupper($objp->nature));
$transferlabel = ($objp->nature && $key != "AccountingJournalType".strtoupper($langs->trans($objp->nature)) ? $key.($journallabel != $key ? ' '.$journallabel : ''): $journallabel);
$key = $langs->trans("AccountingJournalType".$objp->nature); // $objp->nature is 1, 2, 3 ...
$transferlabel = (($objp->nature && $key != "AccountingJournalType".$objp->nature) ? $key.($journallabelwithoutspan != $key ? ' '.$journallabel : ''): $journallabel);
$newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $transferlabel, 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
}

View File

@@ -44,9 +44,6 @@ require_once DOL_DOCUMENT_ROOT .'/ticket/class/ticket.class.php';
//require_once DOL_DOCUMENT_ROOT .'/holiday/class/holiday.class.php'; // Holidays (leave request)
// use Webklex\PHPIMAP;
require DOL_DOCUMENT_ROOT .'/includes/webklex/php-imap/vendor/autoload.php';
use Webklex\PHPIMAP\ClientManager;
use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
use Webklex\PHPIMAP\Exceptions\InvalidWhereQueryCriteriaException;
@@ -1040,6 +1037,9 @@ class EmailCollector extends CommonObject
//$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
require_once DOL_DOCUMENT_ROOT.'/includes/webklex/php-imap/vendor/autoload.php';
}
dol_syslog("EmailCollector::doCollectOneCollector start for id=".$this->id." - ".$this->ref, LOG_DEBUG);

View File

@@ -2566,8 +2566,8 @@ if ($action == 'create') {
print '</table>';
print '</div>';
//var_dump($object);
print '<script javascript>
print '<script>
/* JQuery for product free or predefined select */
jQuery(document).ready(function() {
@@ -2583,6 +2583,10 @@ if ($action == 'create') {
jQuery("#value_unit_ht").val("");
}
});
';
if (! empty($conf->global->MAIN_USE_EXPENSE_IK)) {
print '
/* unit price coéf calculation */
jQuery(".input_qty, #fk_c_type_fees, #select_fk_c_exp_tax_cat, #vatrate ").change(function(event) {
@@ -2628,6 +2632,10 @@ if ($action == 'create') {
jQuery("#value_unit_ht").val("");
}*/
});
';
}
print '
});

View File

@@ -885,8 +885,12 @@ if (empty($reshook)) {
$totalcreditnotes = $facture_source->getSumCreditNotesUsed();
$totaldeposits = $facture_source->getSumDepositsUsed();
$remain_to_pay = abs($facture_source->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits);
$desc = $langs->trans('invoiceAvoirLineWithPaymentRestAmount');
$retAddLine = $object->addline($desc, $remain_to_pay, 0, 0, 0, 1, 0, 0, '', '', 0, '', 'TTC');
$object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'), $remain_to_pay, 0, 0, 0, 1, 0, 0, '', '', 'TTC');
if ($retAddLine < 0) {
$error++;
}
}
}
}

View File

@@ -104,7 +104,7 @@ global $permissiontoadd;
if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlines') {
$situationinvoicelinewithparent = 0;
if ($line->fk_prev_id != null && in_array($object->element, array('facture', 'facturedet'))) {
if ($object->type == $object::TYPE_SITUATION) { // The constant TYPE_SITUATION exists only for object invoice
if (!empty($object->situation_cycle_ref)) {
// Set constant to disallow editing during a situation cycle
$situationinvoicelinewithparent = 1;
}

View File

@@ -26,13 +26,13 @@ if (!function_exists('preg_last_error_msg')) {
function preg_last_error_msg(): string { return p\Php80::preg_last_error_msg(); }
}
if (!function_exists('str_contains')) {
function str_contains(?string $haystack, ?string $needle): bool { return p\Php80::str_contains($haystack ?? '', $needle ?? ''); }
function str_contains($haystack, $needle): bool { return p\Php80::str_contains($haystack ?? '', $needle ?? ''); }
}
if (!function_exists('str_starts_with')) {
function str_starts_with(?string $haystack, ?string $needle): bool { return p\Php80::str_starts_with($haystack ?? '', $needle ?? ''); }
function str_starts_with($haystack, $needle): bool { return p\Php80::str_starts_with($haystack ?? '', $needle ?? ''); }
}
if (!function_exists('str_ends_with')) {
function str_ends_with(?string $haystack, ?string $needle): bool { return p\Php80::str_ends_with($haystack ?? '', $needle ?? ''); }
function str_ends_with($haystack, $needle): bool { return p\Php80::str_ends_with($haystack ?? '', $needle ?? ''); }
}
if (!function_exists('get_debug_type')) {
function get_debug_type($value): string { return p\Php80::get_debug_type($value); }

View File

@@ -446,7 +446,7 @@ NoJournalDefined=No journal defined
Binded=Lines bound
ToBind=Lines to bind
UseMenuToSetBindindManualy=Lines not yet bound, use menu <a href="%s">%s</a> to make the binding manually
SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices=Sorry this module is not compatible with the experimental feature of situation invoices
SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices=Note: this module or page is not completely compatible with the experimental feature of situation invoices. Some data may be wrong.
AccountancyErrorMismatchLetterCode=Mismatch in reconcile code
AccountancyErrorMismatchBalanceAmount=The balance (%s) is not equal to 0
AccountancyErrorLetteringBookkeeping=Errors have occurred concerning the transactions: %s

View File

@@ -1364,7 +1364,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
if ($nbremote == 0 && $nblocal == 0) {
$colspan = (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD) ? 10 : 9);
print '<tr><td colspan="'.$colspan.'"<span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
}
print "</table>";
print "</div>";

View File

@@ -327,76 +327,79 @@ if (empty($reshook)) {
if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
$fk_parent_line = 0;
}
if ($invoice->type == Facture::TYPE_SITUATION) {
$source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id
$line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from
if (!empty($invoice->tab_previous_situation_invoice)) {
// search the last standard invoice in cycle and the possible credit note between this last and invoice
// TODO Move this out of loop of $invoice->lines
$tab_jumped_credit_notes = array();
$lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
$searchPreviousInvoice = true;
while ($searchPreviousInvoice) {
if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) {
$searchPreviousInvoice = false; // find, exit;
break;
} else {
if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) {
$tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
}
$lineIndex--; // go to previous invoice in cycle
}
}
$maxPrevSituationPercent = 0;
foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
if ($prevLine->id == $source_fk_prev_id) {
$maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
//$line->subprice = $line->subprice - $prevLine->subprice;
$line->total_ht = $line->total_ht - $prevLine->total_ht;
$line->total_tva = $line->total_tva - $prevLine->total_tva;
$line->total_ttc = $line->total_ttc - $prevLine->total_ttc;
$line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1;
$line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2;
$line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice;
$line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht;
$line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva;
$line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc;
}
}
// prorata
$line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
//print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'<br>';
// If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta)
$maxPrevSituationPercent = 0;
foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
if ($prevLine->fk_prev_id == $source_fk_prev_id) {
$maxPrevSituationPercent = $prevLine->situation_percent;
$line->total_ht -= $prevLine->total_ht;
$line->total_tva -= $prevLine->total_tva;
$line->total_ttc -= $prevLine->total_ttc;
$line->total_localtax1 -= $prevLine->total_localtax1;
$line->total_localtax2 -= $prevLine->total_localtax2;
$line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
$line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
$line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
$line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
if (getDolGlobalInt('INVOICE_USE_SITUATION')) {
if (!empty($invoice->situation_counter)) {
$source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id
$line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from
if (!empty($invoice->tab_previous_situation_invoice)) {
// search the last standard invoice in cycle and the possible credit note between this last and invoice
// TODO Move this out of loop of $invoice->lines
$tab_jumped_credit_notes = array();
$lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
$searchPreviousInvoice = true;
while ($searchPreviousInvoice) {
if ($invoice->tab_previous_situation_invoice[$lineIndex]->situation_cycle_ref || $lineIndex < 1) {
$searchPreviousInvoice = false; // find, exit;
break;
} else {
if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) {
$tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
}
$lineIndex--; // go to previous invoice in cycle
}
}
$maxPrevSituationPercent = 0;
foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
if ($prevLine->id == $source_fk_prev_id) {
$maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
//$line->subprice = $line->subprice - $prevLine->subprice;
$line->total_ht = $line->total_ht - $prevLine->total_ht;
$line->total_tva = $line->total_tva - $prevLine->total_tva;
$line->total_ttc = $line->total_ttc - $prevLine->total_ttc;
$line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1;
$line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2;
$line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice;
$line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht;
$line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva;
$line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc;
}
}
// prorata
$line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
//print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'<br>';
// If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta)
$maxPrevSituationPercent = 0;
foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
if ($prevLine->fk_prev_id == $source_fk_prev_id) {
$maxPrevSituationPercent = $prevLine->situation_percent;
$line->total_ht -= $prevLine->total_ht;
$line->total_tva -= $prevLine->total_tva;
$line->total_ttc -= $prevLine->total_ttc;
$line->total_localtax1 -= $prevLine->total_localtax1;
$line->total_localtax2 -= $prevLine->total_localtax2;
$line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
$line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
$line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
$line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
}
}
}
// prorata
$line->situation_percent += $maxPrevSituationPercent;
//print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'<br>';
}
// prorata
$line->situation_percent += $maxPrevSituationPercent;
//print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'<br>';
}
}

View File

@@ -129,7 +129,7 @@ if ($user->id != $id && !$canreaduser) {
// Define value to know what current user can do on properties of edited user
if ($id > 0) {
// $user is the current logged user, $id is the user we want to edit
$canedituser = (($user->id == $id) && $user->hasRight("user", "self", "write")); // can edit myself
$canedituser = (($user->id == $id) && $user->hasRight("user", "self", "write")) || (($user->id != $id) && $user->hasRight("user", "user", "write"));
$caneditfield = ((($user->id == $id) && $user->hasRight("user", "self", "write")) || (($user->id != $id) && $user->hasRight("user", "user", "write")));
$caneditpassword = ((($user->id == $id) && $user->hasRight("user", "self", "password")) || (($user->id != $id) && $user->hasRight("user", "user", "password")));
}