This commit is contained in:
Laurent Destailleur 2022-01-28 18:07:34 +01:00
commit adf8f3886b
16 changed files with 421 additions and 153 deletions

View File

@ -626,7 +626,7 @@ class Commande extends CommonOrder
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande";
$sql .= " SET fk_statut = ".self::STATUS_DRAFT."',";
$sql .= " SET fk_statut = ".self::STATUS_DRAFT.",";
$sql .= " fk_user_modif = ".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id);

View File

@ -6,7 +6,7 @@
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Eric Seigne <eric.seigne@cap-rel.fr>
* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2021-2022 Open-Dsi <support@open-dsi.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -47,7 +47,7 @@ $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "produ
$refresh = (GETPOSTISSET('submit') || GETPOSTISSET('vat_rate_show') || GETPOSTISSET('invoice_type')) ? true : false;
$invoice_type = GETPOSTISSET('invoice_type') ? GETPOST('invoice_type', 'alpha') : '';
$vat_rate_show = GETPOSTISSET('vat_rate_show') ? GETPOST('vat_rate_show', 'int') : -1;
$vat_rate_show = GETPOSTISSET('vat_rate_show') ? GETPOST('vat_rate_show', 'alphanohtml') : -1;
include DOL_DOCUMENT_ROOT.'/compta/tva/initdatesforvat.inc.php';
@ -409,7 +409,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) {
print '<td class="tax_rate" colspan="' . ($span+1) . '">';
print $langs->trans('Rate') . ' : ' . vatrate($rate) . '%';
print ' - <a href="'.DOL_URL_ROOT.'/compta/tva/quadri_detail.php?invoice_type=customer';
if (!GETPOSTISSET('vat_rate_show') || GETPOST('vat_rate_show') != $rate) {
if ($invoice_type != 'customer' || !GETPOSTISSET('vat_rate_show') || GETPOST('vat_rate_show') != $rate) {
print '&amp;vat_rate_show='.urlencode($rate);
}
print '&amp;date_startyear='.urlencode($date_start_year).'&amp;date_startmonth='.urlencode($date_start_month).'&amp;date_startday='.urlencode($date_start_day).'&amp;date_endyear='.urlencode($date_end_year).'&amp;date_endmonth='.urlencode($date_end_month).'&amp;date_endday='.urlencode($date_end_day).'">' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . '</a>';
@ -643,7 +643,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) {
print '<td class="tax_rate" colspan="' . ($span+1) . '">';
print $langs->trans('Rate') . ' : ' . vatrate($rate) . '%';
print ' - <a href="'.DOL_URL_ROOT.'/compta/tva/quadri_detail.php?invoice_type=supplier';
if (!GETPOSTISSET('vat_rate_show') || GETPOST('vat_rate_show') != $rate) {
if ($invoice_type != 'supplier' || !GETPOSTISSET('vat_rate_show') || GETPOST('vat_rate_show') != $rate) {
print '&amp;vat_rate_show='.urlencode($rate);
}
print '&amp;date_startyear='.urlencode($date_start_year).'&amp;date_startmonth='.urlencode($date_start_month).'&amp;date_startday='.urlencode($date_start_day).'&amp;date_endyear='.urlencode($date_end_year).'&amp;date_endmonth='.urlencode($date_end_month).'&amp;date_endday='.urlencode($date_end_day).'">' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . '</a>';

View File

@ -804,9 +804,6 @@ class ExtraFields
if ($elementtype == 'order_supplier') {
$elementtype = 'commande_fournisseur';
}
if ($elementtype == 'stock_mouvement') {
$elementtype = 'movement';
}
$array_name_label = array();

View File

@ -109,6 +109,11 @@ function stock_admin_prepare_head()
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/admin/stock_mouvement_extrafields.php';
$head[$h][1] = $langs->trans("StockMouvementExtraFields");
$head[$h][2] = 'stockMouvementAttributes';
$h++;
complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin', 'remove');
return $head;

View File

@ -6,7 +6,7 @@
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2021-2022 Open-Dsi <support@open-dsi.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -696,7 +696,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
|| ($direction == 'buy' && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')) {
// Count on delivery date (use invoice date as delivery is unknown)
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.vat_src_code as vat_src_code, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
$sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
$sql .= " d.date_start as date_start, d.date_end as date_end,";
$sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,";
@ -739,7 +739,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
$sql .= " ORDER BY d.rowid, d.".$fk_facture;
} else {
// Count on payments date
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.vat_src_code as vat_src_code, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
$sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
$sql .= " d.date_start as date_start, d.date_end as date_end,";
$sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,";
@ -799,66 +799,71 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
$rate = -1;
$oldrowid = '';
while ($assoc = $db->fetch_array($resql)) {
$rate_key = $assoc['rate'];
if ($f_rate == 'tva_tx' && !empty($assoc['vat_src_code']) && !preg_match('/\(/', $rate_key)) {
$rate_key .= ' (' . $assoc['vat_src_code'] . ')';
}
// Code to avoid warnings when array entry not defined
if (!isset($list[$assoc['rate']]['totalht'])) {
$list[$assoc['rate']]['totalht'] = 0;
if (!isset($list[$rate_key]['totalht'])) {
$list[$rate_key]['totalht'] = 0;
}
if (!isset($list[$assoc['rate']]['vat'])) {
$list[$assoc['rate']]['vat'] = 0;
if (!isset($list[$rate_key]['vat'])) {
$list[$rate_key]['vat'] = 0;
}
if (!isset($list[$assoc['rate']]['localtax1'])) {
$list[$assoc['rate']]['localtax1'] = 0;
if (!isset($list[$rate_key]['localtax1'])) {
$list[$rate_key]['localtax1'] = 0;
}
if (!isset($list[$assoc['rate']]['localtax2'])) {
$list[$assoc['rate']]['localtax2'] = 0;
if (!isset($list[$rate_key]['localtax2'])) {
$list[$rate_key]['localtax2'] = 0;
}
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
$oldrowid = $assoc['rowid'];
$list[$assoc['rate']]['totalht'] += $assoc['total_ht'];
$list[$assoc['rate']]['vat'] += $assoc['total_vat'];
$list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1'];
$list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2'];
$list[$rate_key]['totalht'] += $assoc['total_ht'];
$list[$rate_key]['vat'] += $assoc['total_vat'];
$list[$rate_key]['localtax1'] += $assoc['total_localtax1'];
$list[$rate_key]['localtax2'] += $assoc['total_localtax2'];
}
$list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc'];
$list[$assoc['rate']]['dtype'][] = $assoc['dtype'];
$list[$assoc['rate']]['datef'][] = $db->jdate($assoc['datef']);
$list[$assoc['rate']]['datep'][] = $db->jdate($assoc['datep']);
$list[$rate_key]['dtotal_ttc'][] = $assoc['total_ttc'];
$list[$rate_key]['dtype'][] = $assoc['dtype'];
$list[$rate_key]['datef'][] = $db->jdate($assoc['datef']);
$list[$rate_key]['datep'][] = $db->jdate($assoc['datep']);
$list[$assoc['rate']]['company_name'][] = $assoc['company_name'];
$list[$assoc['rate']]['company_id'][] = $assoc['company_id'];
$list[$assoc['rate']]['company_alias'][] = $assoc['company_alias'];
$list[$assoc['rate']]['company_email'][] = $assoc['company_email'];
$list[$assoc['rate']]['company_tva_intra'][] = $assoc['company_tva_intra'];
$list[$assoc['rate']]['company_client'][] = $assoc['company_client'];
$list[$assoc['rate']]['company_fournisseur'][] = $assoc['company_fournisseur'];
$list[$assoc['rate']]['company_customer_code'][] = $assoc['company_customer_code'];
$list[$assoc['rate']]['company_supplier_code'][] = $assoc['company_supplier_code'];
$list[$assoc['rate']]['company_customer_accounting_code'][] = $assoc['company_customer_accounting_code'];
$list[$assoc['rate']]['company_supplier_accounting_code'][] = $assoc['company_supplier_accounting_code'];
$list[$assoc['rate']]['company_status'][] = $assoc['company_status'];
$list[$rate_key]['company_name'][] = $assoc['company_name'];
$list[$rate_key]['company_id'][] = $assoc['company_id'];
$list[$rate_key]['company_alias'][] = $assoc['company_alias'];
$list[$rate_key]['company_email'][] = $assoc['company_email'];
$list[$rate_key]['company_tva_intra'][] = $assoc['company_tva_intra'];
$list[$rate_key]['company_client'][] = $assoc['company_client'];
$list[$rate_key]['company_fournisseur'][] = $assoc['company_fournisseur'];
$list[$rate_key]['company_customer_code'][] = $assoc['company_customer_code'];
$list[$rate_key]['company_supplier_code'][] = $assoc['company_supplier_code'];
$list[$rate_key]['company_customer_accounting_code'][] = $assoc['company_customer_accounting_code'];
$list[$rate_key]['company_supplier_accounting_code'][] = $assoc['company_supplier_accounting_code'];
$list[$rate_key]['company_status'][] = $assoc['company_status'];
$list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']);
$list[$assoc['rate']]['ddate_end'][] = $db->jdate($assoc['date_end']);
$list[$rate_key]['ddate_start'][] = $db->jdate($assoc['date_start']);
$list[$rate_key]['ddate_end'][] = $db->jdate($assoc['date_end']);
$list[$assoc['rate']]['facid'][] = $assoc['facid'];
$list[$assoc['rate']]['facnum'][] = $assoc['facnum'];
$list[$assoc['rate']]['type'][] = $assoc['type'];
$list[$assoc['rate']]['ftotal_ttc'][] = $assoc['ftotal_ttc'];
$list[$assoc['rate']]['descr'][] = $assoc['descr'];
$list[$rate_key]['facid'][] = $assoc['facid'];
$list[$rate_key]['facnum'][] = $assoc['facnum'];
$list[$rate_key]['type'][] = $assoc['type'];
$list[$rate_key]['ftotal_ttc'][] = $assoc['ftotal_ttc'];
$list[$rate_key]['descr'][] = $assoc['descr'];
$list[$assoc['rate']]['totalht_list'][] = $assoc['total_ht'];
$list[$assoc['rate']]['vat_list'][] = $assoc['total_vat'];
$list[$assoc['rate']]['localtax1_list'][] = $assoc['total_localtax1'];
$list[$assoc['rate']]['localtax2_list'][] = $assoc['total_localtax2'];
$list[$rate_key]['totalht_list'][] = $assoc['total_ht'];
$list[$rate_key]['vat_list'][] = $assoc['total_vat'];
$list[$rate_key]['localtax1_list'][] = $assoc['total_localtax1'];
$list[$rate_key]['localtax2_list'][] = $assoc['total_localtax2'];
$list[$assoc['rate']]['pid'][] = $assoc['pid'];
$list[$assoc['rate']]['pref'][] = $assoc['pref'];
$list[$assoc['rate']]['ptype'][] = $assoc['ptype'];
$list[$rate_key]['pid'][] = $assoc['pid'];
$list[$rate_key]['pref'][] = $assoc['pref'];
$list[$rate_key]['ptype'][] = $assoc['ptype'];
$list[$assoc['rate']]['payment_id'][] = $assoc['payment_id'];
$list[$assoc['rate']]['payment_ref'][] = $assoc['payment_ref'];
$list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount'];
$list[$rate_key]['payment_id'][] = $assoc['payment_id'];
$list[$rate_key]['payment_ref'][] = $assoc['payment_ref'];
$list[$rate_key]['payment_amount'][] = $assoc['payment_amount'];
$rate = $assoc['rate'];
}
@ -876,7 +881,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')
|| ($direction == 'buy' && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) {
// Count on invoice date
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.vat_src_code as vat_src_code, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
$sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
$sql .= " d.date_start as date_start, d.date_end as date_end,";
$sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,";
@ -919,7 +924,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
$sql .= " ORDER BY d.rowid, d.".$fk_facture;
} else {
// Count on payments date
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.vat_src_code as vat_src_code, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
$sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
$sql .= " d.date_start as date_start, d.date_end as date_end,";
$sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,";
@ -979,66 +984,71 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
$rate = -1;
$oldrowid = '';
while ($assoc = $db->fetch_array($resql)) {
$rate_key = $assoc['rate'];
if ($f_rate == 'tva_tx' && !empty($assoc['vat_src_code']) && !preg_match('/\(/', $rate_key)) {
$rate_key .= ' (' . $assoc['vat_src_code'] . ')';
}
// Code to avoid warnings when array entry not defined
if (!isset($list[$assoc['rate']]['totalht'])) {
$list[$assoc['rate']]['totalht'] = 0;
if (!isset($list[$rate_key]['totalht'])) {
$list[$rate_key]['totalht'] = 0;
}
if (!isset($list[$assoc['rate']]['vat'])) {
$list[$assoc['rate']]['vat'] = 0;
if (!isset($list[$rate_key]['vat'])) {
$list[$rate_key]['vat'] = 0;
}
if (!isset($list[$assoc['rate']]['localtax1'])) {
$list[$assoc['rate']]['localtax1'] = 0;
if (!isset($list[$rate_key]['localtax1'])) {
$list[$rate_key]['localtax1'] = 0;
}
if (!isset($list[$assoc['rate']]['localtax2'])) {
$list[$assoc['rate']]['localtax2'] = 0;
if (!isset($list[$rate_key]['localtax2'])) {
$list[$rate_key]['localtax2'] = 0;
}
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
$oldrowid = $assoc['rowid'];
$list[$assoc['rate']]['totalht'] += $assoc['total_ht'];
$list[$assoc['rate']]['vat'] += $assoc['total_vat'];
$list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1'];
$list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2'];
$list[$rate_key]['totalht'] += $assoc['total_ht'];
$list[$rate_key]['vat'] += $assoc['total_vat'];
$list[$rate_key]['localtax1'] += $assoc['total_localtax1'];
$list[$rate_key]['localtax2'] += $assoc['total_localtax2'];
}
$list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc'];
$list[$assoc['rate']]['dtype'][] = $assoc['dtype'];
$list[$assoc['rate']]['datef'][] = $db->jdate($assoc['datef']);
$list[$assoc['rate']]['datep'][] = $db->jdate($assoc['datep']);
$list[$rate_key]['dtotal_ttc'][] = $assoc['total_ttc'];
$list[$rate_key]['dtype'][] = $assoc['dtype'];
$list[$rate_key]['datef'][] = $db->jdate($assoc['datef']);
$list[$rate_key]['datep'][] = $db->jdate($assoc['datep']);
$list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']);
$list[$assoc['rate']]['ddate_end'][] = $db->jdate($assoc['date_end']);
$list[$rate_key]['ddate_start'][] = $db->jdate($assoc['date_start']);
$list[$rate_key]['ddate_end'][] = $db->jdate($assoc['date_end']);
$list[$assoc['rate']]['company_name'][] = $assoc['company_name'];
$list[$assoc['rate']]['company_id'][] = $assoc['company_id'];
$list[$assoc['rate']]['company_alias'][] = $assoc['company_alias'];
$list[$assoc['rate']]['company_email'][] = $assoc['company_email'];
$list[$assoc['rate']]['company_tva_intra'][] = $assoc['company_tva_intra'];
$list[$assoc['rate']]['company_client'][] = $assoc['company_client'];
$list[$assoc['rate']]['company_fournisseur'][] = $assoc['company_fournisseur'];
$list[$assoc['rate']]['company_customer_code'][] = $assoc['company_customer_code'];
$list[$assoc['rate']]['company_supplier_code'][] = $assoc['company_supplier_code'];
$list[$assoc['rate']]['company_customer_accounting_code'][] = $assoc['company_customer_accounting_code'];
$list[$assoc['rate']]['company_supplier_accounting_code'][] = $assoc['company_supplier_accounting_code'];
$list[$assoc['rate']]['company_status'][] = $assoc['company_status'];
$list[$rate_key]['company_name'][] = $assoc['company_name'];
$list[$rate_key]['company_id'][] = $assoc['company_id'];
$list[$rate_key]['company_alias'][] = $assoc['company_alias'];
$list[$rate_key]['company_email'][] = $assoc['company_email'];
$list[$rate_key]['company_tva_intra'][] = $assoc['company_tva_intra'];
$list[$rate_key]['company_client'][] = $assoc['company_client'];
$list[$rate_key]['company_fournisseur'][] = $assoc['company_fournisseur'];
$list[$rate_key]['company_customer_code'][] = $assoc['company_customer_code'];
$list[$rate_key]['company_supplier_code'][] = $assoc['company_supplier_code'];
$list[$rate_key]['company_customer_accounting_code'][] = $assoc['company_customer_accounting_code'];
$list[$rate_key]['company_supplier_accounting_code'][] = $assoc['company_supplier_accounting_code'];
$list[$rate_key]['company_status'][] = $assoc['company_status'];
$list[$assoc['rate']]['facid'][] = $assoc['facid'];
$list[$assoc['rate']]['facnum'][] = $assoc['facnum'];
$list[$assoc['rate']]['type'][] = $assoc['type'];
$list[$assoc['rate']]['ftotal_ttc'][] = $assoc['ftotal_ttc'];
$list[$assoc['rate']]['descr'][] = $assoc['descr'];
$list[$rate_key]['facid'][] = $assoc['facid'];
$list[$rate_key]['facnum'][] = $assoc['facnum'];
$list[$rate_key]['type'][] = $assoc['type'];
$list[$rate_key]['ftotal_ttc'][] = $assoc['ftotal_ttc'];
$list[$rate_key]['descr'][] = $assoc['descr'];
$list[$assoc['rate']]['totalht_list'][] = $assoc['total_ht'];
$list[$assoc['rate']]['vat_list'][] = $assoc['total_vat'];
$list[$assoc['rate']]['localtax1_list'][] = $assoc['total_localtax1'];
$list[$assoc['rate']]['localtax2_list'][] = $assoc['total_localtax2'];
$list[$rate_key]['totalht_list'][] = $assoc['total_ht'];
$list[$rate_key]['vat_list'][] = $assoc['total_vat'];
$list[$rate_key]['localtax1_list'][] = $assoc['total_localtax1'];
$list[$rate_key]['localtax2_list'][] = $assoc['total_localtax2'];
$list[$assoc['rate']]['pid'][] = $assoc['pid'];
$list[$assoc['rate']]['pref'][] = $assoc['pref'];
$list[$assoc['rate']]['ptype'][] = $assoc['ptype'];
$list[$rate_key]['pid'][] = $assoc['pid'];
$list[$rate_key]['pref'][] = $assoc['pref'];
$list[$rate_key]['ptype'][] = $assoc['ptype'];
$list[$assoc['rate']]['payment_id'][] = $assoc['payment_id'];
$list[$assoc['rate']]['payment_ref'][] = $assoc['payment_ref'];
$list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount'];
$list[$rate_key]['payment_id'][] = $assoc['payment_id'];
$list[$rate_key]['payment_ref'][] = $assoc['payment_ref'];
$list[$rate_key]['payment_amount'][] = $assoc['payment_amount'];
$rate = $assoc['rate'];
}
@ -1056,7 +1066,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
$sql = '';
// Count on payments date
$sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,";
$sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.vat_src_code as vat_src_code, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,";
$sql .= " d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, ";
$sql .= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,";
$sql .= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,";
@ -1101,55 +1111,60 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
$rate = -1;
$oldrowid = '';
while ($assoc = $db->fetch_array($resql)) {
$rate_key = $assoc['rate'];
if ($f_rate == 'tva_tx' && !empty($assoc['vat_src_code']) && !preg_match('/\(/', $rate_key)) {
$rate_key .= ' (' . $assoc['vat_src_code'] . ')';
}
// Code to avoid warnings when array entry not defined
if (!isset($list[$assoc['rate']]['totalht'])) {
$list[$assoc['rate']]['totalht'] = 0;
if (!isset($list[$rate_key]['totalht'])) {
$list[$rate_key]['totalht'] = 0;
}
if (!isset($list[$assoc['rate']]['vat'])) {
$list[$assoc['rate']]['vat'] = 0;
if (!isset($list[$rate_key]['vat'])) {
$list[$rate_key]['vat'] = 0;
}
if (!isset($list[$assoc['rate']]['localtax1'])) {
$list[$assoc['rate']]['localtax1'] = 0;
if (!isset($list[$rate_key]['localtax1'])) {
$list[$rate_key]['localtax1'] = 0;
}
if (!isset($list[$assoc['rate']]['localtax2'])) {
$list[$assoc['rate']]['localtax2'] = 0;
if (!isset($list[$rate_key]['localtax2'])) {
$list[$rate_key]['localtax2'] = 0;
}
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
$oldrowid = $assoc['rowid'];
$list[$assoc['rate']]['totalht'] += $assoc['total_ht'];
$list[$assoc['rate']]['vat'] += $assoc['total_vat'];
$list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1'];
$list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2'];
$list[$rate_key]['totalht'] += $assoc['total_ht'];
$list[$rate_key]['vat'] += $assoc['total_vat'];
$list[$rate_key]['localtax1'] += $assoc['total_localtax1'];
$list[$rate_key]['localtax2'] += $assoc['total_localtax2'];
}
$list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc'];
$list[$assoc['rate']]['dtype'][] = 'ExpenseReportPayment';
$list[$assoc['rate']]['datef'][] = $assoc['datef'];
$list[$assoc['rate']]['company_name'][] = '';
$list[$assoc['rate']]['company_id'][] = '';
$list[$assoc['rate']]['user_id'][] = $assoc['fk_user_author'];
$list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']);
$list[$assoc['rate']]['ddate_end'][] = $db->jdate($assoc['date_end']);
$list[$rate_key]['dtotal_ttc'][] = $assoc['total_ttc'];
$list[$rate_key]['dtype'][] = 'ExpenseReportPayment';
$list[$rate_key]['datef'][] = $assoc['datef'];
$list[$rate_key]['company_name'][] = '';
$list[$rate_key]['company_id'][] = '';
$list[$rate_key]['user_id'][] = $assoc['fk_user_author'];
$list[$rate_key]['ddate_start'][] = $db->jdate($assoc['date_start']);
$list[$rate_key]['ddate_end'][] = $db->jdate($assoc['date_end']);
$list[$assoc['rate']]['facid'][] = $assoc['facid'];
$list[$assoc['rate']]['facnum'][] = $assoc['facnum'];
$list[$assoc['rate']]['type'][] = $assoc['type'];
$list[$assoc['rate']]['ftotal_ttc'][] = $assoc['ftotal_ttc'];
$list[$assoc['rate']]['descr'][] = $assoc['descr'];
$list[$rate_key]['facid'][] = $assoc['facid'];
$list[$rate_key]['facnum'][] = $assoc['facnum'];
$list[$rate_key]['type'][] = $assoc['type'];
$list[$rate_key]['ftotal_ttc'][] = $assoc['ftotal_ttc'];
$list[$rate_key]['descr'][] = $assoc['descr'];
$list[$assoc['rate']]['totalht_list'][] = $assoc['total_ht'];
$list[$assoc['rate']]['vat_list'][] = $assoc['total_vat'];
$list[$assoc['rate']]['localtax1_list'][] = $assoc['total_localtax1'];
$list[$assoc['rate']]['localtax2_list'][] = $assoc['total_localtax2'];
$list[$rate_key]['totalht_list'][] = $assoc['total_ht'];
$list[$rate_key]['vat_list'][] = $assoc['total_vat'];
$list[$rate_key]['localtax1_list'][] = $assoc['total_localtax1'];
$list[$rate_key]['localtax2_list'][] = $assoc['total_localtax2'];
$list[$assoc['rate']]['pid'][] = $assoc['pid'];
$list[$assoc['rate']]['pref'][] = $assoc['pref'];
$list[$assoc['rate']]['ptype'][] = 'ExpenseReportPayment';
$list[$rate_key]['pid'][] = $assoc['pid'];
$list[$rate_key]['pref'][] = $assoc['pref'];
$list[$rate_key]['ptype'][] = 'ExpenseReportPayment';
$list[$assoc['rate']]['payment_id'][] = $assoc['payment_id'];
$list[$assoc['rate']]['payment_ref'][] = $assoc['payment_ref'];
$list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount'];
$list[$rate_key]['payment_id'][] = $assoc['payment_id'];
$list[$rate_key]['payment_ref'][] = $assoc['payment_ref'];
$list[$rate_key]['payment_amount'][] = $assoc['payment_amount'];
$rate = $assoc['rate'];
}

View File

@ -87,3 +87,10 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) value
INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_MODIFY','Expense report modified','Executed when an expense report is modified','expensereport',202);
INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_MODIFY','Expense report modified','Executed when an expense report is modified','expensereport',212);
CREATE TABLE llx_stock_mouvement_extrafields (
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14)
)ENGINE=innodb;

View File

@ -0,0 +1,24 @@
-- ===================================================================
-- Copyright (C) 2022 Salvatore Chiariello <sal.chiariello@gmail.com>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
--
-- ===================================================================
CREATE TABLE llx_stock_mouvement_extrafields (
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14)
)ENGINE=innodb;

View File

@ -410,3 +410,4 @@ DefaultBOMDesc=The default BOM recommended to use to manufacture this product. T
Rank=Rank
SwitchOnSaleStatus=Switch on sale status
SwitchOnPurchaseStatus=Switch on purchase status
StockMouvementExtraFields= Extra Fields (stock mouvement)

View File

@ -410,3 +410,4 @@ DefaultBOMDesc=The default BOM recommended to use to manufacture this product. T
Rank=Rank
SwitchOnSaleStatus=Switch on sale status
SwitchOnPurchaseStatus=Switch on purchase status
StockMouvementExtraFields= Campi extra (movimenti scorte)

View File

@ -0,0 +1,123 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.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/product/admin/stock_mouvement_extrafields.php
* \ingroup stock
* \brief Page to setup extra fields of stock mouvement
*/
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
// Try main.inc.php using relative path
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('stock@stock', 'admin'));
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'stock_mouvement'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden();
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
/*
* View
*/
llxHeader('', $langs->trans("StockSetup"), $help_url);
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("StockSetup"), $linkback, 'title_setup');
$head = stock_admin_prepare_head();
print dol_get_fiche_head($head, 'stockMouvementAttributes', $langs->trans("StockMouvementExtraFields"), -1, 'account');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
print dol_get_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
}
/*
* Creation of an optional field
*/
if ($action == 'create') {
print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
/*
* Edition of an optional field
*/
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
// End of page
llxFooter();
$db->close();

View File

@ -655,11 +655,13 @@ class FormProduct
}
foreach ($productIdArray as $productId) {
foreach ($this->cache_lot[$productId] as $id => $arraytypes) {
if (empty($fk_entrepot) || $fk_entrepot == $arraytypes['entrepot_id']) {
$label = $arraytypes['entrepot_label'].' - ';
$label .= $arraytypes['batch'];
$out .= '<option>'.$arraytypes['batch'].'</option>';
if (array_key_exists($productId, $this->cache_lot)) {
foreach ($this->cache_lot[$productId] as $id => $arraytypes) {
if (empty($fk_entrepot) || $fk_entrepot == $arraytypes['entrepot_id']) {
$label = $arraytypes['entrepot_label'] . ' - ';
$label .= $arraytypes['batch'];
$out .= '<option>' . $arraytypes['batch'] . '</option>';
}
}
}
}

View File

@ -5120,9 +5120,10 @@ class Product extends CommonObject
* @param string $origin_element Origin element type
* @param int $origin_id Origin id of element
* @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (usefull only if product is a subproduct)
* @return int <0 if KO, >0 if OK
* @param array $extrafields Array of extrafields
* @return int <0 if KO, >0 if OK
*/
public function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0)
public function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0, $extrafields = null)
{
// phpcs:enable
if ($id_entrepot) {
@ -5145,6 +5146,11 @@ class Product extends CommonObject
$result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', '', '', '', false, 0, $disablestockchangeforsubproduct);
if ($result >= 0) {
if ($extrafields) {
$array_options = $extrafields->getOptionalsFromPost('stock_mouvement');
$movementstock->array_options = $array_options;
$movementstock->insertExtraFields();
}
$this->db->commit();
return 1;
} else {
@ -5174,9 +5180,10 @@ class Product extends CommonObject
* @param string $origin_element Origin element type
* @param int $origin_id Origin id of element
* @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (usefull only if product is a subproduct)
* @param array $extrafields Array of extrafields
* @return int <0 if KO, >0 if OK
*/
public function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0)
public function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0, $extrafields = null)
{
// phpcs:enable
if ($id_entrepot) {
@ -5199,6 +5206,11 @@ class Product extends CommonObject
$result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', $dlc, $dluo, $lot, false, 0, $disablestockchangeforsubproduct);
if ($result >= 0) {
if ($extrafields) {
$array_options = $extrafields->getOptionalsFromPost('stock_mouvement');
$movementstock->array_options = $array_options;
$movementstock->insertExtraFields();
}
$this->db->commit();
return 1;
} else {

View File

@ -139,6 +139,9 @@ $arrayfields = array(
//'m.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
//'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500)
);
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
if (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
unset($arrayfields['pl.sellby']);
}
@ -381,7 +384,9 @@ if ($action == "correct_stock") {
$batch,
GETPOST('inventorycode', 'alphanohtml'),
$origin_element,
$origin_id
$origin_id,
0,
$extrafields
); // We do not change value of stock for a correction
} else {
$result = $product->correct_stock(
@ -393,7 +398,9 @@ if ($action == "correct_stock") {
price2num(GETPOST('unitprice'), 'MT'),
GETPOST('inventorycode', 'alphanohtml'),
$origin_element,
$origin_id
$origin_id,
0,
$extrafields
); // We do not change value of stock for a correction
}
@ -500,7 +507,11 @@ if ($action == "transfert_stock" && !$cancel) {
$eatby,
$sellby,
$batch,
GETPOST('inventorycode')
GETPOST('inventorycode'),
'',
null,
0,
$extrafields
);
// Add stock
$result2 = $product->correct_stock_batch(
@ -513,7 +524,11 @@ if ($action == "transfert_stock" && !$cancel) {
$eatby,
$sellby,
$batch,
GETPOST('inventorycode', 'alphanohtml')
GETPOST('inventorycode', 'alphanohtml'),
'',
null,
0,
$extrafields
);
}
} else {
@ -525,7 +540,11 @@ if ($action == "transfert_stock" && !$cancel) {
1,
GETPOST("label", 'san_alpha'),
$pricesrc,
GETPOST('inventorycode', 'alphanohtml')
GETPOST('inventorycode', 'alphanohtml'),
'',
null,
0,
$extrafields
);
// Add stock
@ -536,7 +555,11 @@ if ($action == "transfert_stock" && !$cancel) {
0,
GETPOST("label", 'san_alpha'),
$pricedest,
GETPOST('inventorycode', 'alphanohtml')
GETPOST('inventorycode', 'alphanohtml'),
'',
null,
0,
$extrafields
);
}
if (!$error && $result1 >= 0 && $result2 >= 0) {
@ -1434,6 +1457,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
}
// Extra fields
$object = $movement;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);

View File

@ -0,0 +1,51 @@
<?php
/* Copyright (C) 2014 Maxime Kohlhaas <support@atm-consulting.fr>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
*
* 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/>.
*
* Need to have following variables defined:
* $object (invoice, order, ...)
* $action
* $conf
* $langs
*
* $parameters
* $cols
*/
// Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) {
print "Error, template page can't be called as URL";
exit;
}
?>
<!-- BEGIN PHP TEMPLATE extrafields_add.tpl.php -->
<?php
// Other attributes
if (!isset($parameters)) $parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $movement, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook)) {
$params = array();
if (isset($tpl_context)) $params['tpl_context'] = $tpl_context;
$params['cols'] = $parameters['colspanvalue'];
print $movement->showOptionals($extrafields, 'create', $params);
}
?>
<!-- END PHP TEMPLATE extrafields_add.tpl.php -->

View File

@ -179,6 +179,9 @@ print '<input class="maxwidth100onsmartphone" name="inventorycode" id="inventory
print '</td>';
print '</tr>';
// Extrafield template
include 'extrafields_add.tpl.php';
print '</table>';
print dol_get_fiche_end();

View File

@ -136,6 +136,9 @@ print '<input class="maxwidth100onsmartphone" name="inventorycode" id="inventory
print '</td>';
print '</tr>';
// Extrafield template
include 'extrafields_add.tpl.php';
print '</table>';
print dol_get_fiche_end();