';
diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php
index be458d41fe3..ecde836c428 100644
--- a/htdocs/comm/mailing/list.php
+++ b/htdocs/comm/mailing/list.php
@@ -103,7 +103,7 @@ if (empty($reshook)) {
}*/
$search_ref = '';
$search_all = '';
- $toselect = '';
+ $toselect = array();
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index f4f77afc4d8..485b5b0daf9 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -14,6 +14,7 @@
* Copyright (C) 2016 Marcos García
* Copyright (C) 2018-2021 Frédéric France
* Copyright (C) 2020 Nicolas ZABOURI
+ * Copyright (C) 2022 Gauthier VERDOL
*
* 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
@@ -80,6 +81,7 @@ $confirm = GETPOST('confirm', 'alpha');
$lineid = GETPOST('lineid', 'int');
$contactid = GETPOST('contactid', 'int');
$projectid = GETPOST('projectid', 'int');
+$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1;
// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@@ -116,7 +118,7 @@ $usercandelete = $user->rights->propal->supprimer;
$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->close)));
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate)));
-$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send);
+$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->send)));
$usercancreateorder = $user->rights->commande->creer;
$usercancreateinvoice = $user->rights->facture->creer;
@@ -879,6 +881,13 @@ if (empty($reshook)) {
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
}
+ } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) {
+ // Define vat_rate
+ $remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0);
+ $remise_percent = str_replace('*', '', $remise_percent);
+ foreach ($object->lines as $line) {
+ $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
+ }
} elseif ($action == 'addline' && $usercancreate) { // Add line
// Set if we used free entry or predefined product
$predef = '';
@@ -1196,7 +1205,7 @@ if (empty($reshook)) {
setEventMessages($mesg, null, 'errors');
} else {
// Insert line
- $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise);
+ $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise);
if ($result > 0) {
$db->commit();
@@ -1627,19 +1636,19 @@ if ($action == 'create') {
print '';
// Reference
- print ''.$langs->trans('Ref').' '.$langs->trans("Draft").' ';
+ print ''.$langs->trans('Ref').' '.$langs->trans("Draft").' ';
// Ref customer
- print ''.$langs->trans('RefCustomer').' ';
+ print ' '.$langs->trans('RefCustomer').' ';
print ' ';
print ' ';
// Third party
- print '';
- print ''.$langs->trans('Customer').' ';
+ print ' ';
+ print ''.$langs->trans('Customer').' ';
$shipping_method_id = 0;
if ($socid > 0) {
- print '';
+ print ' ';
print $soc->getNomUrl(1);
print ' ';
print ' ';
@@ -1648,7 +1657,7 @@ if ($action == 'create') {
}
//$warehouse_id = $soc->warehouse_id;
} else {
- print '';
+ print ' ';
print img_picto('', 'company').$form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx');
// reload page to retrieve customer informations
if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) {
@@ -1671,13 +1680,13 @@ if ($action == 'create') {
if ($socid > 0) {
// Contacts (ask contact only if thirdparty already defined).
- print " ".$langs->trans("DefaultContact").' ';
+ print ' '.$langs->trans("DefaultContact").' ';
print img_picto('', 'contact');
print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, '', '', 0, 'minwidth300');
print ' ';
// Third party discounts info line
- print ''.$langs->trans('Discounts').' ';
+ print ' '.$langs->trans('Discounts').' ';
$absolute_discount = $soc->getAvailableDiscounts();
@@ -1689,12 +1698,12 @@ if ($action == 'create') {
}
// Date
- print ' '.$langs->trans('DatePropal').' ';
+ print ' '.$langs->trans('DatePropal').' ';
print $form->selectDate('', '', '', '', '', "addprop", 1, 1);
print ' ';
// Validaty duration
- print ''.$langs->trans("ValidityDuration").' '.img_picto('', 'clock').' '.$langs->trans("days").' ';
+ print ''.$langs->trans("ValidityDuration").' '.img_picto('', 'clock', 'class="paddingright"').' '.$langs->trans("days").' ';
// Terms of payment
print ''.$langs->trans('PaymentConditionsShort').' ';
@@ -1703,31 +1712,31 @@ if ($action == 'create') {
print ' ';
// Mode of payment
- print ''.$langs->trans('PaymentMode').' ';
- print img_picto('', 'bank').' ';
+ print ' '.$langs->trans('PaymentMode').' ';
+ print img_picto('', 'bank', 'class="pictofixedwidth"');
$form->select_types_paiements((GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $soc->mode_reglement_id), 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx');
print ' ';
// Bank Account
if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) {
- print ''.$langs->trans('BankAccount').' ';
+ print ' '.$langs->trans('BankAccount').' ';
print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes($soc->fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1);
print ' ';
}
// Source / Channel - What trigger creation
- print ''.$langs->trans('Source').' ';
+ print ' '.$langs->trans('Source').' ';
print img_picto('', 'question', 'class="pictofixedwidth"');
$form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1, 'maxwidth200 widthcentpercentminusx');
print ' ';
// Delivery delay
- print ''.$langs->trans('AvailabilityPeriod');
+ print ' '.$langs->trans('AvailabilityPeriod');
if (!empty($conf->commande->enabled)) {
print ' ('.$langs->trans('AfterOrder').')';
}
- print ' ';
- print img_picto('', 'clock').' ';
+ print ' ';
+ print img_picto('', 'clock', 'class="pictofixedwidth"');
$form->selectAvailabilityDelay('', 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx');
print ' ';
@@ -1736,7 +1745,7 @@ if ($action == 'create') {
if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) {
$shipping_method_id = $soc->shipping_method_id;
}
- print ''.$langs->trans('SendingMethod').' ';
+ print ' '.$langs->trans('SendingMethod').' ';
print img_picto('', 'object_dollyrevert', 'class="pictofixedwidth"');
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx');
print ' ';
@@ -1746,14 +1755,14 @@ if ($action == 'create') {
if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
- print ''.$langs->trans('Warehouse').' ';
+ print ' '.$langs->trans('Warehouse').' ';
print img_picto('', 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx');
print ' ';
}
// Delivery date (or manufacturing)
- print ''.$langs->trans("DeliveryDate").' ';
- print '';
+ print ' '.$langs->trans("DeliveryDate").' ';
+ print '';
if (isset($conf->global->DATE_LIVRAISON_WEEK_DELAY) && is_numeric($conf->global->DATE_LIVRAISON_WEEK_DELAY)) {
$tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60);
$syear = date("Y", $tmpdte);
@@ -1768,8 +1777,8 @@ if ($action == 'create') {
// Project
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
- print ' ';
- print ''.$langs->trans("Project").' ';
+ print ' ';
+ print ''.$langs->trans("Project").' ';
print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx');
print ' id).'"> ';
print ' ';
@@ -1778,18 +1787,18 @@ if ($action == 'create') {
// Incoterms
if (!empty($conf->incoterm->enabled)) {
- print ' ';
- print ''.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->label_incoterms, 1).' ';
- print '';
+ print ' ';
+ print ''.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->label_incoterms, 1).' ';
+ print '';
print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms) ? $soc->location_incoterms : ''));
print ' ';
}
// Template to use by default
- print '';
- print ''.$langs->trans("DefaultModel").' ';
- print '';
- print img_picto('', 'pdf').' ';
+ print ' ';
+ print ''.$langs->trans("DefaultModel").' ';
+ print '';
+ print img_picto('', 'pdf', 'class="pictofixedwidth"');
$liste = ModelePDFPropales::liste_modeles($db);
$preselected = (!empty($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT) ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : getDolGlobalString("PROPALE_ADDON_PDF"));
print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
@@ -1797,26 +1806,26 @@ if ($action == 'create') {
// Multicurrency
if (!empty($conf->multicurrency->enabled)) {
- print ' ';
- print ''.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).' ';
- print '';
- print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
+ print ' ';
+ print ''.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).' ';
+ print '';
+ print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
print ' ';
}
// Public note
- print '';
- print ''.$langs->trans('NotePublic').' ';
- print '';
+ print ' ';
+ print ''.$langs->trans('NotePublic').' ';
+ print '';
$note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc) ? $objectsrc->note_public : null));
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
// Private note
if (empty($user->socid)) {
- print ' ';
- print ''.$langs->trans('NotePrivate').' ';
- print '';
+ print ' ';
+ print ''.$langs->trans('NotePrivate').' ';
+ print '';
$note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc)) ? $objectsrc->note_private : null));
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
@@ -1942,11 +1951,13 @@ if ($action == 'create') {
$title = $langs->trans('ProductsAndServices');
print load_fiche_titre($title);
+ print '';
print '
';
$objectsrc->printOriginLinesList();
print '
';
+ print '
';
}
} elseif ($object->id > 0) {
/*
@@ -1967,7 +1978,7 @@ if ($action == 'create') {
$formquestion = array(
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
- array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)')),
+ array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', '', 0, 0, null, 0, 'maxwidth300')),
array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans('PuttingPricesUpToDate'), 'value' => (!empty($conf->global->PROPOSAL_CLONE_UPDATE_PRICES) ? 1 : 0)),
);
if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->delivery_date)) {
@@ -2341,9 +2352,9 @@ if ($action == 'create') {
print ' ';
// Payment mode
- print '';
- print '';
- print '';
+ print ' ';
+ print '';
+ print '';
print $langs->trans('PaymentMode');
print ' ';
if ($action != 'editmode' && $usercancreate && $caneditfield) {
@@ -2362,7 +2373,7 @@ if ($action == 'create') {
$langs->load('deliveries');
print '';
print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker');
- print ' ';
+ print ' ';
print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker');
print ' ';
print ' ';
@@ -2393,7 +2404,7 @@ if ($action == 'create') {
// Shipping Method
if (!empty($conf->expedition->enabled)) {
print '';
- print '';
+ print '';
print $langs->trans('SendingMethod');
print ' ';
if ($action != 'editshippingmethod' && $usercancreate && $caneditfield) {
@@ -2415,7 +2426,7 @@ if ($action == 'create') {
$langs->load('stocks');
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
- print '';
+ print ' ';
$editenable = $usercancreate;
print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable);
print ' ';
@@ -2430,7 +2441,7 @@ if ($action == 'create') {
// Origin of demand
print ' ';
- print '';
+ print '';
print $langs->trans('Source');
print ' ';
if ($action != 'editdemandreason' && $usercancreate) {
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index b109424ee70..0d7c301f7b0 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -17,6 +17,7 @@
* Copyright (C) 2018 Ferran Marcet
* Copyright (C) 2022 ATM Consulting
* Copyright (C) 2022 OpenDSI
+ * Copyright (C) 2022 Gauthier VERDOL
*
* 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
@@ -746,6 +747,11 @@ class Propal extends CommonObject
// Reorder if child line
if (!empty($fk_parent_line)) {
$this->line_order(true, 'DESC');
+ } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines
+ $linecount = count($this->lines);
+ for ($ii = $ranktouse; $ii <= $linecount; $ii++) {
+ $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1);
+ }
}
// Mise a jour informations denormalisees au niveau de la propale meme
@@ -1789,8 +1795,9 @@ class Propal extends CommonObject
*/
public function fetch_lines($only_product = 0, $loadalsotranslation = 0, $filters = '')
{
- global $langs, $conf;
// phpcs:enable
+ global $langs, $conf;
+
$this->lines = array();
$sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
@@ -3827,8 +3834,24 @@ class Propal extends CommonObject
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
-}
+ /**
+ * Function used to replace a product id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old product id
+ * @param int $dest_id New product id
+ * @return bool
+ */
+ public static function replaceProduct(DoliDB $db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'propaldet'
+ );
+
+ return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables);
+ }
+}
/**
* Class to manage commercial proposal lines
@@ -4432,7 +4455,7 @@ class PropaleLigne extends CommonObjectLine
if (!$error && !$notrigger) {
// Call trigger
- $result = $this->call_trigger('LINEPROPAL_UPDATE', $user);
+ $result = $this->call_trigger('LINEPROPAL_MODIFY', $user);
if ($result < 0) {
$this->db->rollback();
return -1;
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index 8c1df4f56e4..eb5b310edd1 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -123,6 +123,15 @@ $search_fk_input_reason = GETPOST("search_fk_input_reason", 'int');
$search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'int');
$search_btn = GETPOST('button_search', 'alpha');
$search_remove_btn = GETPOST('button_removefilter', 'alpha');
+$search_date_signature_startday = GETPOST('search_date_signature_startday', 'int');
+$search_date_signature_startmonth = GETPOST('search_date_signature_startmonth', 'int');
+$search_date_signature_startyear = GETPOST('search_date_signature_startyear', 'int');
+$search_date_signature_endday = GETPOST('search_date_signature_endday', 'int');
+$search_date_signature_endmonth = GETPOST('search_date_signature_endmonth', 'int');
+$search_date_signature_endyear = GETPOST('search_date_signature_endyear', 'int');
+$search_date_signature_start = dol_mktime(0, 0, 0, $search_date_signature_startmonth, $search_date_signature_startday, $search_date_signature_startyear);
+$search_date_signature_end = dol_mktime(23, 59, 59, $search_date_signature_endmonth, $search_date_signature_endday, $search_date_signature_endyear);
+
$search_status = GETPOST('search_status', 'alpha');
$optioncss = GETPOST('optioncss', 'alpha');
@@ -207,6 +216,7 @@ $arrayfields = array(
'p.date'=>array('label'=>"DatePropal", 'checked'=>1),
'p.fin_validite'=>array('label'=>"DateEnd", 'checked'=>1),
'p.date_livraison'=>array('label'=>"DeliveryDate", 'checked'=>0),
+ 'p.date_signature'=>array('label'=>"DateSigning", 'checked'=>0),
'ava.rowid'=>array('label'=>"AvailabilityPeriod", 'checked'=>0),
'p.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>0, 'enabled'=>!empty($conf->expedition->enabled)),
'p.fk_input_reason'=>array('label'=>"Origin", 'checked'=>0, 'enabled'=>1),
@@ -330,13 +340,21 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_availability = '';
$search_status = '';
$object_statut = '';
- $toselect = '';
+ $toselect = array();
$search_array_options = array();
$search_categ_cus = 0;
$search_fk_cond_reglement = '';
$search_fk_shipping_method = '';
$search_fk_input_reason = '';
$search_fk_mode_reglement = '';
+ $search_date_signature_startday = '';
+ $search_date_signature_startmonth = '';
+ $search_date_signature_startyear = '';
+ $search_date_signature_endday = '';
+ $search_date_signature_endmonth = '';
+ $search_date_signature_endyear = '';
+ $search_date_signature_start = '';
+ $search_date_signature_end = '';
}
if ($object_statut != '') {
$search_status = $object_statut;
@@ -361,7 +379,7 @@ if ($action == 'validate' && $permissiontovalidate) {
if ($tmpproposal->valid($user) > 0) {
setEventMessage($langs->trans('hasBeenValidated', $tmpproposal->ref), 'mesgs');
} else {
- setEventMessage($langs->trans('CantBeValidated'), 'errors');
+ setEventMessage($tmpproposal->error, $tmpproposal->errors, 'errors');
$error++;
}
} else {
@@ -398,7 +416,7 @@ if ($action == "sign" && $permissiontoclose) {
$error++;
}
} else {
- setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors');
+ setEventMessage($langs->trans('MustBeValidatedToBeSigned', $tmpproposal->ref), 'errors');
$error++;
}
} else {
@@ -517,6 +535,7 @@ $sql .= " state.code_departement as state_code, state.nom as state_name,";
$sql .= ' p.rowid, p.entity as propal_entity, p.note_private, p.total_ht, p.total_tva, p.total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut as status, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,';
$sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc,';
$sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,';
+$sql .= ' p.date_signature as dsignature,';
$sql .= ' p.note_public, p.note_private,';
$sql .= ' p.fk_cond_reglement,p.deposit_percent,p.fk_mode_reglement,p.fk_shipping_method,p.fk_input_reason,';
$sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,";
@@ -701,6 +720,12 @@ if ($search_sale > 0) {
if ($search_user > 0) {
$sql .= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".((int) $search_user);
}
+if ($search_date_signature_start) {
+ $sql .= " AND p.date_signature >= '".$db->idate($search_date_signature_start)."'";
+}
+if ($search_date_signature_end) {
+ $sql .= " AND p.date_signature <= '".$db->idate($search_date_signature_end)."'";
+}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@@ -917,6 +942,24 @@ if ($resql) {
if ($search_country) {
$param .= '&search_country='.urlencode($search_country);
}
+ if ($search_date_signature_startday) {
+ $param .= '&search_date_signature_startday='.urlencode($search_date_signature_startday);
+ }
+ if ($search_date_signature_startmonth) {
+ $param .= '&search_date_signature_startmonth='.urlencode($search_date_signature_startmonth);
+ }
+ if ($search_date_signature_startyear) {
+ $param .= '&search_date_signature_startyear='.urlencode($search_date_signature_startyear);
+ }
+ if ($search_date_signature_endday) {
+ $param .= '&search_date_signature_endday='.urlencode($search_date_signature_endday);
+ }
+ if ($search_date_signature_endmonth) {
+ $param .= '&search_date_signature_endmonth='.urlencode($search_date_signature_endmonth);
+ }
+ if ($search_date_signature_endyear) {
+ $param .= '&search_date_signature_endyear='.urlencode($search_date_signature_endyear);
+ }
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@@ -1000,7 +1043,7 @@ if ($resql) {
$moreforfilter = '';
// If the user can view prospects other than his'
- if ($user->rights->societe->client->voir || $socid) {
+ if ($user->rights->user->user->lire) {
$langs->load("commercial");
$moreforfilter .= '';
$tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
@@ -1008,9 +1051,9 @@ if ($resql) {
$moreforfilter .= '
';
}
// If the user can view prospects other than his'
- if ($user->rights->societe->client->voir || $socid) {
+ if ($user->rights->user->user->lire) {
$moreforfilter .= '';
- $tmptitle = $langs->trans('LinkedToSpecificUsers');
+ $tmptitle = $langs->trans('LinkedToSpecificUsers');
$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
$moreforfilter .= '
';
}
@@ -1148,6 +1191,17 @@ if ($resql) {
print '';
print '';
}
+ // Date Signature
+ if (!empty($arrayfields['p.date_signature']['checked'])) {
+ print '';
+ print '';
+ print $form->selectDate($search_date_signature_start ? $search_date_signature_start : -1, 'search_date_signature_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+ print '
';
+ print '';
+ print $form->selectDate($search_date_signature_end ? $search_date_signature_end : -1, 'search_date_signature_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+ print '
';
+ print ' ';
+ }
// Availability
if (!empty($arrayfields['ava.rowid']['checked'])) {
print '';
@@ -1361,7 +1415,10 @@ if ($resql) {
print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'align="center"', $sortfield, $sortorder);
}
if (!empty($arrayfields['p.date_livraison']['checked'])) {
- print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'ddelivery', '', $param, 'align="center"', $sortfield, $sortorder);
+ print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'p.date_livraison', '', $param, 'align="center"', $sortfield, $sortorder);
+ }
+ if (!empty($arrayfields['p.date_signature']['checked'])) {
+ print_liste_field_titre($arrayfields['p.date_signature']['label'], $_SERVER["PHP_SELF"], 'p.date_signature', '', $param, 'align="center"', $sortfield, $sortorder);
}
if (!empty($arrayfields['ava.rowid']['checked'])) {
print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder);
@@ -1720,6 +1777,18 @@ if ($resql) {
$totalarray['nbfield']++;
}
}
+ // Date Signature
+ if (!empty($arrayfields['p.date_signature']['checked'])) {
+ if ($obj->dsignature) {
+ print ' '.dol_print_date($db->jdate($obj->dsignature), 'day');
+ print ' ';
+ } else {
+ print ' ';
+ }
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
// Availability
if (!empty($arrayfields['ava.rowid']['checked'])) {
print '';
@@ -2028,7 +2097,7 @@ if ($resql) {
// Note public
if (!empty($arrayfields['p.note_public']['checked'])) {
print ' ';
- print dol_escape_htmltag($obj->note_public);
+ print dol_string_nohtmltag($obj->note_public);
print ' ';
if (!$i) {
$totalarray['nbfield']++;
@@ -2037,7 +2106,7 @@ if ($resql) {
// Note private
if (!empty($arrayfields['p.note_private']['checked'])) {
print '';
- print dol_escape_htmltag($obj->note_private);
+ print dol_string_nohtmltag($obj->note_private);
print ' ';
if (!$i) {
$totalarray['nbfield']++;
diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php
index d44093dbab5..c0e96aa4b15 100644
--- a/htdocs/comm/remx.php
+++ b/htdocs/comm/remx.php
@@ -62,7 +62,7 @@ if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
exit;
}
-if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $user->rights->societe->creer) {
+if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && ($user->rights->societe->creer || $user->rights->facture->creer)) {
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
@@ -153,7 +153,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $user-
}
}
-if ($action == 'setremise' && $user->rights->societe->creer) {
+if ($action == 'setremise' && ($user->rights->societe->creer || $user->rights->facture->creer)) {
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
@@ -192,7 +192,7 @@ if ($action == 'setremise' && $user->rights->societe->creer) {
}
}
-if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && $user->rights->societe->creer) {
+if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && ($user->rights->societe->creer || $user->rights->facture->creer)) {
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 96350de5d8f..1a35ff937b9 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -13,6 +13,7 @@
* Copyright (C) 2014 Ferran Marcet
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2018-2021 Frédéric France
+ * Copyright (C) 2022 Gauthier VERDOL
*
* 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
@@ -81,6 +82,7 @@ $contactid = GETPOST('contactid', 'int');
$projectid = GETPOST('projectid', 'int');
$origin = GETPOST('origin', 'alpha');
$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility
+$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1;
// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@@ -627,6 +629,13 @@ if (empty($reshook)) {
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
}
+ } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) {
+ // Define remise_percent
+ $remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0);
+ $remise_percent = str_replace('*', '', $remise_percent);
+ foreach ($object->lines as $line) {
+ $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
+ }
} elseif ($action == 'addline' && $usercancreate) { // Add a new line
$langs->load('errors');
$error = 0;
@@ -940,7 +949,7 @@ if (empty($reshook)) {
setEventMessages($mesg, null, 'errors');
} else {
// Insert line
- $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise);
+ $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise);
if ($result > 0) {
$ret = $object->fetch($object->id); // Reload to get new records
@@ -1723,7 +1732,7 @@ if ($action == 'create' && $usercancreate) {
// Terms of the settlement
print ''.$langs->trans('PaymentConditionsShort').' ';
- print img_picto('', 'paiment');
+ print img_picto('', 'paiment', 'class="pictofixedwidth"');
$form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, '', $deposit_percent);
print ' ';
@@ -1812,10 +1821,10 @@ if ($action == 'create' && $usercancreate) {
// Template to use by default
print ''.$langs->trans('DefaultModel').' ';
print '';
- print img_picto('', 'pdf', 'class="pictofixedwidth"');
include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
$liste = ModelePDFCommandes::liste_modeles($db);
$preselected = $conf->global->COMMANDE_ADDON_PDF;
+ print img_picto('', 'pdf', 'class="pictofixedwidth"');
print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
print " ";
@@ -1824,7 +1833,7 @@ if ($action == 'create' && $usercancreate) {
print '';
print ''.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).' ';
print '';
- print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
+ print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code');
print ' ';
}
@@ -1917,11 +1926,13 @@ if ($action == 'create' && $usercancreate) {
$title = $langs->trans('ProductsAndServices');
print load_fiche_titre($title);
+ print '';
print '
';
$objectsrc->printOriginLinesList('', $selectedLines);
print '
';
+ print '
';
}
print '';
@@ -2199,7 +2210,7 @@ if ($action == 'create' && $usercancreate) {
if ($action == 'clone') {
// Create an array for form
$formquestion = array(
- array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client = 2 OR s.client=3)'))
+ array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client = 2 OR s.client=3)', '', 0, 0, null, 0, 'maxwidth300'))
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
@@ -2680,27 +2691,27 @@ if ($action == 'create' && $usercancreate) {
if (empty($reshook)) {
// Reopen a closed order
if (($object->statut == Commande::STATUS_CLOSED || $object->statut == Commande::STATUS_CANCELED) && $usercancreate) {
- print ''.$langs->trans('ReOpen').' ';
+ print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, '');
}
// Send
if (empty($user->socid)) {
if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) {
if ($usercansend) {
- print 'id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').' ';
+ print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?action=presend&token='.newToken().'&id='.$object->id.'&mode=init#formmailbeforetitle', '');
} else {
- print ''.$langs->trans('SendMail').' ';
+ print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
}
}
}
// Valid
if ($object->statut == Commande::STATUS_DRAFT && ($object->total_ttc >= 0 || !empty($conf->global->ORDER_ENABLE_NEGATIVE)) && $numlines > 0 && $usercanvalidate) {
- print 'id.'&action=validate">'.$langs->trans('Validate').' ';
+ print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, '');
}
// Edit
if ($object->statut == Commande::STATUS_VALIDATED && $usercancreate) {
- print ''.$langs->trans('Modify').' ';
+ print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=modif&token='.newToken().'&id='.$object->id, '');
}
// Create event
/*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD))
@@ -2715,7 +2726,7 @@ if ($action == 'create' && $usercancreate) {
if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) {
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) {
if ($usercancreatepurchaseorder) {
- print ''.$langs->trans("AddPurchaseOrder").' ';
+ print dolGetButtonAction('', $langs->trans('AddPurchaseOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, '');
}
}
}
@@ -2726,9 +2737,9 @@ if ($action == 'create' && $usercancreate) {
if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) {
if ($user->rights->ficheinter->creer) {
- print ''.$langs->trans('AddIntervention').' ';
+ print dolGetButtonAction('', $langs->trans('AddInterventionGR'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, '');
} else {
- print ''.$langs->trans('AddIntervention').' ';
+ print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('AddIntervention'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
}
}
}
@@ -2738,7 +2749,7 @@ if ($action == 'create' && $usercancreate) {
$langs->load("contracts");
if ($user->rights->contrat->creer) {
- print ''.$langs->trans('AddContract').' ';
+ print dolGetButtonAction('', $langs->trans('AddContract'), 'default', DOL_URL_ROOT.'/contrat/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, '');
}
}
@@ -2750,52 +2761,52 @@ if ($action == 'create' && $usercancreate) {
if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->creer)) {
if ($user->rights->expedition->creer) {
- print ''.$langs->trans('CreateShipment').' ';
+ print dolGetButtonAction('', $langs->trans('CreateShipment'), 'default', DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id, '');
} else {
- print ''.$langs->trans('CreateShipment').' ';
+ print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('CreateShipment'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
}
} else {
$langs->load("errors");
- print 'transnoentitiesnoconv("Shipment"))).'">'.$langs->trans('CreateShipment').' ';
+ print dolGetButtonAction($langs->trans('ErrorModuleSetupNotComplete'), $langs->trans('CreateShipment'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
}
}
}
// Set to shipped
if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS) && $usercanclose) {
- print 'id.'&action=shipped">'.$langs->trans('ClassifyShipped').' ';
+ print dolGetButtonAction('', $langs->trans('ClassifyShipped'), 'default', $_SERVER["PHP_SELF"].'?action=shipped&token='.newToken().'&id='.$object->id, '');
}
// Create bill and Classify billed
// Note: Even if module invoice is not enabled, we should be able to use button "Classified billed"
if ($object->statut > Commande::STATUS_DRAFT && !$object->billed && $object->total_ttc >= 0) {
if (!empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
- print ''.$langs->trans("CreateBill").' ';
+ print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&token='.newToken().'&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, '');
}
if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
- print 'id.'&action=classifybilled&token='.newToken().'">'.$langs->trans("ClassifyBilled").' ';
+ print dolGetButtonAction('', $langs->trans('ClassifyBilled'), 'default', $_SERVER["PHP_SELF"].'?action=classifybilled&token='.newToken().'&id='.$object->id, '');
}
}
if ($object->statut > Commande::STATUS_DRAFT && $object->billed) {
if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
- print 'id.'&action=classifyunbilled&token='.newToken().'">'.$langs->trans("ClassifyUnBilled").' ';
+ print dolGetButtonAction('', $langs->trans('ClassifyUnBilled'), 'default', $_SERVER["PHP_SELF"].'?action=classifyunbilled&token='.newToken().'&id='.$object->id, '');
}
}
// Clone
if ($usercancreate) {
- print ''.$langs->trans("ToClone").' ';
+ print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER["PHP_SELF"].'?action=clone&token='.newToken().'&id='.$object->id.'&socid='.$object->socid, '');
}
// Cancel order
if ($object->statut == Commande::STATUS_VALIDATED && (!empty($usercanclose) || !empty($usercancancel))) {
- print 'id.'&action=cancel&token='.newToken().'">'.$langs->trans("Cancel").' ';
+ print dolGetButtonAction('', $langs->trans('Cancel'), 'danger', $_SERVER["PHP_SELF"].'?action=cancel&token='.newToken().'&id='.$object->id, '');
}
// Delete order
if ($usercandelete) {
if ($numshipping == 0) {
- print 'id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').' ';
+ print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, '');
} else {
- print ''.$langs->trans("Delete").' ';
+ print dolGetButtonAction($langs->trans('ShippingExist'), $langs->trans('Delete'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
}
}
}
diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php
index fb912139d5f..17528001d1b 100644
--- a/htdocs/commande/class/api_orders.class.php
+++ b/htdocs/commande/class/api_orders.class.php
@@ -135,6 +135,11 @@ class Orders extends DolibarrApi
// Add external contacts ids
$this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', $contact_list);
$this->commande->fetchObjectLinked();
+
+ // Add online_payment_url, cf #20477
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
+ $this->commande->online_payment_url = getOnlinePaymentUrl(0, 'order', $this->commande->ref);
+
return $this->_cleanObjectDatas($this->commande);
}
@@ -230,6 +235,10 @@ class Orders extends DolibarrApi
if ($commande_static->fetch($obj->rowid)) {
// Add external contacts ids
$commande_static->contacts_ids = $commande_static->liste_contact(-1, 'external', 1);
+ // Add online_payment_url, cf #20477
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
+ $commande_static->online_payment_url = getOnlinePaymentUrl(0, 'order', $commande_static->ref);
+
$obj_ret[] = $this->_cleanObjectDatas($commande_static);
}
$i++;
@@ -735,6 +744,10 @@ class Orders extends DolibarrApi
$this->commande->fetchObjectLinked();
+ //fix #20477 : add online_payment_url
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
+ $this->commande->online_payment_url = getOnlinePaymentUrl(0, 'order', $this->commande->ref);
+
return $this->_cleanObjectDatas($this->commande);
}
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 47dc10537d4..ca149d1f681 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -12,6 +12,7 @@
* Copyright (C) 2018 Nicolas ZABOURI
* Copyright (C) 2016-2022 Ferran Marcet
* Copyright (C) 2021-2022 Frédéric France
+ * Copyright (C) 2022 Gauthier VERDOL
*
* 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
@@ -271,6 +272,11 @@ class Commande extends CommonOrder
*/
public $expeditions;
+ /**
+ * @var string payment url
+ */
+ public $online_payment_url;
+
/**
* 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
@@ -1671,6 +1677,11 @@ class Commande extends CommonOrder
// Reorder if child line
if (!empty($fk_parent_line)) {
$this->line_order(true, 'DESC');
+ } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines
+ $linecount = count($this->lines);
+ for ($ii = $ranktouse; $ii <= $linecount; $ii++) {
+ $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1);
+ }
}
// Mise a jour informations denormalisees au niveau de la commande meme
@@ -2041,8 +2052,9 @@ class Commande extends CommonOrder
*/
public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
{
- global $langs, $conf;
// phpcs:enable
+ global $langs, $conf;
+
$this->lines = array();
$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx, l.ref_ext,';
@@ -4044,6 +4056,23 @@ class Commande extends CommonOrder
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
+ /**
+ * Function used to replace a product id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old product id
+ * @param int $dest_id New product id
+ * @return bool
+ */
+ public static function replaceProduct(DoliDB $db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'commandedet',
+ );
+
+ return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables);
+ }
+
/**
* Is the customer order delayed?
*
@@ -4642,7 +4671,7 @@ class OrderLine extends CommonOrderLine
if (!$error && !$notrigger) {
// Call trigger
- $result = $this->call_trigger('LINEORDER_UPDATE', $user);
+ $result = $this->call_trigger('LINEORDER_MODIFY', $user);
if ($result < 0) {
$error++;
}
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 6f386295eaa..b2bf9615d17 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -201,6 +201,7 @@ $arrayfields = array(
'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)), 'position'=>140),
'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(!empty($conf->expedition->enabled)), 'position'=>990),
'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)), 'position'=>995),
+ 'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999),
'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
);
// Extra fields
@@ -266,7 +267,7 @@ if (empty($reshook)) {
$search_project = '';
$search_status = '';
$search_billed = '';
- $toselect = '';
+ $toselect = array();
$search_array_options = array();
$search_categ_cus = 0;
$search_datecloture_start = '';
@@ -301,6 +302,352 @@ if (empty($reshook)) {
$uploaddir = $conf->commande->multidir_output[$conf->entity];
$triggersendname = 'ORDER_SENTBYMAIL';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
+
+ if ($massaction == 'confirm_createbills') { // Create bills from orders.
+ $orders = GETPOST('toselect', 'array');
+ $createbills_onebythird = GETPOST('createbills_onebythird', 'int');
+ $validate_invoices = GETPOST('validate_invoices', 'int');
+
+ $errors = array();
+
+ $TFact = array();
+ $TFactThird = array();
+ $TFactThirdNbLines = array();
+
+ $nb_bills_created = 0;
+ $lastid= 0;
+ $lastref = '';
+
+ $db->begin();
+
+ foreach ($orders as $id_order) {
+ $cmd = new Commande($db);
+ if ($cmd->fetch($id_order) <= 0) {
+ continue;
+ }
+ $cmd->fetch_thirdparty();
+
+ $objecttmp = new Facture($db);
+ if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
+ // If option "one bill per third" is set, and an invoice for this thirdparty was already created, we re-use it.
+ $objecttmp = $TFactThird[$cmd->socid];
+ } else {
+ // If we want one invoice per order or if there is no first invoice yet for this thirdparty.
+ $objecttmp->socid = $cmd->socid;
+ $objecttmp->thirdparty = $cmd->thirdparty;
+
+ $objecttmp->type = $objecttmp::TYPE_STANDARD;
+ $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id;
+ $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id;
+
+ $objecttmp->fk_project = $cmd->fk_project;
+ $objecttmp->multicurrency_code = $cmd->multicurrency_code;
+ if (empty($createbills_onebythird)) {
+ $objecttmp->ref_client = $cmd->ref_client;
+ }
+
+ $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
+ if (empty($datefacture)) {
+ $datefacture = dol_now();
+ }
+
+ $objecttmp->date = $datefacture;
+ $objecttmp->origin = 'commande';
+ $objecttmp->origin_id = $id_order;
+
+ $objecttmp->array_options = $cmd->array_options; // Copy extrafields
+
+ $res = $objecttmp->create($user);
+
+ if ($res > 0) {
+ $nb_bills_created++;
+ $lastref = $objecttmp->ref;
+ $lastid = $objecttmp->id;
+
+ $TFactThird[$cmd->socid] = $objecttmp;
+ $TFactThirdNbLines[$cmd->socid] = 0; //init nblines to have lines ordered by expedition and rang
+ } else {
+ $langs->load("errors");
+ $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]);
+ $error++;
+ }
+ }
+
+ if ($objecttmp->id > 0) {
+ $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order);
+
+ if ($res == 0) {
+ $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]);
+ $error++;
+ }
+
+ if (!$error) {
+ $lines = $cmd->lines;
+ if (empty($lines) && method_exists($cmd, 'fetch_lines')) {
+ $cmd->fetch_lines();
+ $lines = $cmd->lines;
+ }
+
+ $fk_parent_line = 0;
+ $num = count($lines);
+
+ for ($i = 0; $i < $num; $i++) {
+ $desc = ($lines[$i]->desc ? $lines[$i]->desc : '');
+ // If we build one invoice for several orders, we must put the ref of order on the invoice line
+ if (!empty($createbills_onebythird)) {
+ $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day'));
+ }
+
+ if ($lines[$i]->subprice < 0) {
+ // Negative line, we create a discount line
+ $discount = new DiscountAbsolute($db);
+ $discount->fk_soc = $objecttmp->socid;
+ $discount->amount_ht = abs($lines[$i]->total_ht);
+ $discount->amount_tva = abs($lines[$i]->total_tva);
+ $discount->amount_ttc = abs($lines[$i]->total_ttc);
+ $discount->tva_tx = $lines[$i]->tva_tx;
+ $discount->fk_user = $user->id;
+ $discount->description = $desc;
+ $discountid = $discount->create($user);
+ if ($discountid > 0) {
+ $result = $objecttmp->insert_discount($discountid);
+ //$result=$discount->link_to_invoice($lineid,$id);
+ } else {
+ setEventMessages($discount->error, $discount->errors, 'errors');
+ $error++;
+ break;
+ }
+ } else {
+ // Positive line
+ $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
+ // Date start
+ $date_start = false;
+ if ($lines[$i]->date_debut_prevue) {
+ $date_start = $lines[$i]->date_debut_prevue;
+ }
+ if ($lines[$i]->date_debut_reel) {
+ $date_start = $lines[$i]->date_debut_reel;
+ }
+ if ($lines[$i]->date_start) {
+ $date_start = $lines[$i]->date_start;
+ }
+ //Date end
+ $date_end = false;
+ if ($lines[$i]->date_fin_prevue) {
+ $date_end = $lines[$i]->date_fin_prevue;
+ }
+ if ($lines[$i]->date_fin_reel) {
+ $date_end = $lines[$i]->date_fin_reel;
+ }
+ if ($lines[$i]->date_end) {
+ $date_end = $lines[$i]->date_end;
+ }
+ // Reset fk_parent_line for no child products and special product
+ if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
+ $fk_parent_line = 0;
+ }
+
+ // Extrafields
+ if (method_exists($lines[$i], 'fetch_optionals')) {
+ $lines[$i]->fetch_optionals();
+ $array_options = $lines[$i]->array_options;
+ }
+
+ $objecttmp->context['createfromclone'];
+
+ $rang = $lines[$i]->rang;
+ //there may already be rows from previous orders
+ if (!empty($createbills_onebythird))
+ $rang = $TFactThirdNbLines[$cmd->socid];
+
+ $result = $objecttmp->addline(
+ $desc,
+ $lines[$i]->subprice,
+ $lines[$i]->qty,
+ $lines[$i]->tva_tx,
+ $lines[$i]->localtax1_tx,
+ $lines[$i]->localtax2_tx,
+ $lines[$i]->fk_product,
+ $lines[$i]->remise_percent,
+ $date_start,
+ $date_end,
+ 0,
+ $lines[$i]->info_bits,
+ $lines[$i]->fk_remise_except,
+ 'HT',
+ 0,
+ $product_type,
+ $rang,
+ $lines[$i]->special_code,
+ $objecttmp->origin,
+ $lines[$i]->rowid,
+ $fk_parent_line,
+ $lines[$i]->fk_fournprice,
+ $lines[$i]->pa_ht,
+ $lines[$i]->label,
+ $array_options,
+ 100,
+ 0,
+ $lines[$i]->fk_unit
+ );
+ if ($result > 0) {
+ $lineid = $result;
+ if (!empty($createbills_onebythird)) //increment rang to keep order
+ $TFactThirdNbLines[$rcp->socid]++;
+ } else {
+ $lineid = 0;
+ $error++;
+ break;
+ }
+ // Defined the new fk_parent_line
+ if ($result > 0 && $lines[$i]->product_type == 9) {
+ $fk_parent_line = $result;
+ }
+ }
+ }
+ }
+ }
+
+ //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module.
+
+ if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
+ $TFactThird[$cmd->socid] = $objecttmp;
+ } else {
+ $TFact[$objecttmp->id] = $objecttmp;
+ }
+ }
+
+ // Build doc with all invoices
+ $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
+ $toselect = array();
+
+ if (!$error && $validate_invoices) {
+ $massaction = $action = 'builddoc';
+
+ foreach ($TAllFact as &$objecttmp) {
+ $result = $objecttmp->validate($user);
+ if ($result <= 0) {
+ $error++;
+ setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
+ break;
+ }
+
+ $id = $objecttmp->id; // For builddoc action
+
+ // Builddoc
+ $donotredirect = 1;
+ $upload_dir = $conf->facture->dir_output;
+ $permissiontoadd = $user->rights->facture->creer;
+
+ // Call action to build doc
+ $savobject = $object;
+ $object = $objecttmp;
+ include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
+ $object = $savobject;
+ }
+
+ $massaction = $action = 'confirm_createbills';
+ }
+
+ if (!$error) {
+ $db->commit();
+
+ if ($nb_bills_created == 1) {
+ $texttoshow = $langs->trans('BillXCreated', '{s1}');
+ $texttoshow = str_replace('{s1}', ''.$lastref.' ', $texttoshow);
+ setEventMessages($texttoshow, null, 'mesgs');
+ } else {
+ setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
+ }
+
+ // Make a redirect to avoid to bill twice if we make a refresh or back
+ $param = '';
+ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+ $param .= '&contextpage='.urlencode($contextpage);
+ }
+ if ($limit > 0 && $limit != $conf->liste_limit) {
+ $param .= '&limit='.urlencode($limit);
+ }
+ if ($sall) {
+ $param .= '&sall='.urlencode($sall);
+ }
+ if ($socid > 0) {
+ $param .= '&socid='.urlencode($socid);
+ }
+ if ($search_status != '') {
+ $param .= '&search_status='.urlencode($search_status);
+ }
+ if ($search_orderday) {
+ $param .= '&search_orderday='.urlencode($search_orderday);
+ }
+ if ($search_ordermonth) {
+ $param .= '&search_ordermonth='.urlencode($search_ordermonth);
+ }
+ if ($search_orderyear) {
+ $param .= '&search_orderyear='.urlencode($search_orderyear);
+ }
+ if ($search_deliveryday) {
+ $param .= '&search_deliveryday='.urlencode($search_deliveryday);
+ }
+ if ($search_deliverymonth) {
+ $param .= '&search_deliverymonth='.urlencode($search_deliverymonth);
+ }
+ if ($search_deliveryyear) {
+ $param .= '&search_deliveryyear='.urlencode($search_deliveryyear);
+ }
+ if ($search_ref) {
+ $param .= '&search_ref='.urlencode($search_ref);
+ }
+ if ($search_company) {
+ $param .= '&search_company='.urlencode($search_company);
+ }
+ if ($search_ref_customer) {
+ $param .= '&search_ref_customer='.urlencode($search_ref_customer);
+ }
+ if ($search_user > 0) {
+ $param .= '&search_user='.urlencode($search_user);
+ }
+ if ($search_sale > 0) {
+ $param .= '&search_sale='.urlencode($search_sale);
+ }
+ if ($search_total_ht != '') {
+ $param .= '&search_total_ht='.urlencode($search_total_ht);
+ }
+ if ($search_total_vat != '') {
+ $param .= '&search_total_vat='.urlencode($search_total_vat);
+ }
+ if ($search_total_ttc != '') {
+ $param .= '&search_total_ttc='.urlencode($search_total_ttc);
+ }
+ if ($search_project_ref >= 0) {
+ $param .= "&search_project_ref=".urlencode($search_project_ref);
+ }
+ if ($show_files) {
+ $param .= '&show_files='.urlencode($show_files);
+ }
+ if ($optioncss != '') {
+ $param .= '&optioncss='.urlencode($optioncss);
+ }
+ if ($billed != '') {
+ $param .= '&billed='.urlencode($billed);
+ }
+
+ header("Location: ".$_SERVER['PHP_SELF'].'?'.$param);
+ exit;
+ } else {
+ $db->rollback();
+
+ $action = 'create';
+ $_GET["origin"] = $_POST["origin"];
+ $_GET["originid"] = $_POST["originid"];
+ if (!empty($errors)) {
+ setEventMessages(null, $errors, 'errors');
+ } else {
+ setEventMessages("Error", null, 'errors');
+ }
+ $error++;
+ }
+ }
}
if ($action == 'validate' && $permissiontoadd) {
if (GETPOST('confirm') == 'yes') {
@@ -318,7 +665,7 @@ if ($action == 'validate' && $permissiontoadd) {
if ($objecttmp->valid($user, $idwarehouse)) {
setEventMessage($langs->trans('hasBeenValidated', $objecttmp->ref), 'mesgs');
} else {
- setEventMessage($langs->trans('CantBeValidated'), 'errors');
+ setEventMessage($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
}
} else {
@@ -345,7 +692,7 @@ if ($action == 'shipped' && $permissiontoadd) {
$error = 0;
foreach ($toselect as $checked) {
if ($objecttmp->fetch($checked)) {
- if ($objecttmp->statut == 1) {
+ if ($objecttmp->statut == 1 || $objecttmp->statut == 2) {
if ($objecttmp->cloture($user)) {
setEventMessage($langs->trans('PassedInClosedStatus', $objecttmp->ref), 'mesgs');
} else {
@@ -441,7 +788,7 @@ $sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture
$sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender,';
$sql .= ' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
-$sql .= ' c.fk_input_reason';
+$sql .= ' c.fk_input_reason, c.import_key';
if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
$sql .= ", cc.fk_categorie, cc.fk_soc";
}
@@ -974,7 +1321,7 @@ if ($resql) {
$moreforfilter = '';
// If the user can view prospects other than his'
- if ($user->rights->societe->client->voir || $socid) {
+ if ($user->rights->user->user->lire) {
$langs->load("commercial");
$moreforfilter .= '';
$tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
@@ -1275,6 +1622,11 @@ if ($resql) {
print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1);
print '';
}
+ // Import key
+ if (!empty($arrayfields['c.import_key']['checked'])) {
+ print '
';
+ print ' ';
+ }
// Status
if (!empty($arrayfields['c.fk_statut']['checked'])) {
print '
';
@@ -1436,6 +1788,9 @@ if ($resql) {
if (!empty($arrayfields['c.facture']['checked'])) {
print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center ');
}
+ if (!empty($arrayfields['c.import_key']['checked'])) {
+ print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
+ }
if (!empty($arrayfields['c.fk_statut']['checked'])) {
print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
}
@@ -1935,8 +2290,8 @@ if ($resql) {
// Note public
if (!empty($arrayfields['c.note_public']['checked'])) {
- print ' ';
- print dol_escape_htmltag($obj->note_public);
+ print ' ';
+ print dol_string_nohtmltag($obj->note_public);
print ' ';
if (!$i) {
$totalarray['nbfield']++;
@@ -1945,8 +2300,8 @@ if ($resql) {
// Note private
if (!empty($arrayfields['c.note_private']['checked'])) {
- print '
';
- print dol_escape_htmltag($obj->note_private);
+ print ' ';
+ print dol_string_nohtmltag($obj->note_private);
print ' ';
if (!$i) {
$totalarray['nbfield']++;
@@ -2063,6 +2418,13 @@ if ($resql) {
$totalarray['nbfield']++;
}
}
+ // Import key
+ if (!empty($arrayfields['c.import_key']['checked'])) {
+ print '
'.$obj->import_key.' ';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ }
// Status
if (!empty($arrayfields['c.fk_statut']['checked'])) {
print '
'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).' ';
diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php
index 3d2dee9a286..603627ee91e 100644
--- a/htdocs/commande/stats/index.php
+++ b/htdocs/commande/stats/index.php
@@ -45,8 +45,14 @@ if ($mode == 'customer' && !$user->rights->commande->lire) {
if ($mode == 'supplier' && empty($user->rights->fournisseur->commande->lire)) {
accessforbidden();
}
+if ($mode == 'supplier') {
+ $object_status = GETPOST('object_status', 'array:int');
+ $object_status = implode(',', $object_status);
+} else {
+ $object_status = GETPOST('object_status', 'intcomma');
+}
+
-$object_status = GETPOST('object_status', 'intcomma');
$typent_id = GETPOST('typent_id', 'int');
$categ_id = GETPOST('categ_id', 'categ_id');
diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php
index 1f821bf733b..8f61261bc11 100644
--- a/htdocs/compta/accounting-files.php
+++ b/htdocs/compta/accounting-files.php
@@ -19,11 +19,11 @@
* along with this program. If not, see
.
*/
- /**
- * \file htdocs/compta/accounting-files.php
- * \ingroup compta
- * \brief Page to show portoflio and files of a thirdparty and download it
- */
+/**
+ * \file htdocs/compta/accounting-files.php
+ * \ingroup compta
+ * \brief Page to show portoflio and files of a thirdparty and download it
+ */
if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file
if (!defined('NOTOKENRENEWAL')) {
@@ -588,14 +588,13 @@ foreach ($listofchoices as $choice => $val) {
print '
'.$langs->trans($val['label']).'
';
}
-print '
';
+print '
';
print ''."\n";
print dol_get_fiche_end();
if (!empty($date_start) && !empty($date_stop)) {
- $param = 'action=searchfiles';
$param .= '&date_startday='.GETPOST('date_startday', 'int');
$param .= '&date_startmonth='.GETPOST('date_startmonth', 'int');
$param .= '&date_startyear='.GETPOST('date_startyear', 'int');
@@ -603,13 +602,30 @@ if (!empty($date_start) && !empty($date_stop)) {
$param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int');
$param .= '&date_stopyear='.GETPOST('date_stopyear', 'int');
foreach ($listofchoices as $choice => $val) {
- $param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0);
+ if (GETPOST($choice, 'int')) {
+ $param .= '&'.$choice.'=1';
+ }
}
- print '
'."\n";
+ */
print '
';
@@ -645,172 +666,181 @@ if (!empty($date_start) && !empty($date_stop)) {
print '
'.$langs->trans("Currency").' ';
}
print '
';
- if ($result) {
- $TData = dol_sort_array($filesarray, $sortfield, $sortorder);
- if (empty($TData)) {
- print ''.$langs->trans("NoItem").' ';
- if (!empty($conf->multicurrency->enabled)) {
- print ' ';
+ if (empty($TData)) {
+ print ''.$langs->trans("NoRecordFound").' ';
+ if (!empty($conf->multicurrency->enabled)) {
+ print ' ';
+ }
+ print ' ';
+ } else {
+ // Sort array by date ASC to calculate balance
+
+ $totalET_debit = 0;
+ $totalIT_debit = 0;
+ $totalVAT_debit = 0;
+ $totalET_credit = 0;
+ $totalIT_credit = 0;
+ $totalVAT_credit = 0;
+
+ // Display array
+ foreach ($TData as $data) {
+ $html_class = '';
+ //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
+ //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
+ print '';
+
+ // Type
+ print ''.$langs->trans($data['item']).' ';
+
+ // Date
+ print '';
+ print dol_print_date($data['date'], 'day');
+ print " \n";
+
+ // Date due
+ print '';
+ print dol_print_date($data['date_due'], 'day');
+ print " \n";
+
+ // Ref
+ print '';
+
+ if ($data['item'] == 'Invoice') {
+ $invoice->id = $data['id'];
+ $invoice->ref = $data['ref'];
+ $invoice->total_ht = $data['amount_ht'];
+ $invoice->total_ttc = $data['amount_ttc'];
+ $invoice->total_tva = $data['amount_vat'];
+ $invoice->multicurrency_code = $data['currency'];
+ print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
+ } elseif ($data['item'] == 'SupplierInvoice') {
+ $supplier_invoice->id = $data['id'];
+ $supplier_invoice->ref = $data['ref'];
+ $supplier_invoice->total_ht = $data['amount_ht'];
+ $supplier_invoice->total_ttc = $data['amount_ttc'];
+ $supplier_invoice->total_tva = $data['amount_vat'];
+ $supplier_invoice->multicurrency_code = $data['currency'];
+ print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
+ } elseif ($data['item'] == 'ExpenseReport') {
+ $expensereport->id = $data['id'];
+ $expensereport->ref = $data['ref'];
+ print $expensereport->getNomUrl(1, 0, 0, '', 0, 0);
+ } elseif ($data['item'] == 'SalaryPayment') {
+ $salary_payment->id = $data['id'];
+ $salary_payment->ref = $data['ref'];
+ print $salary_payment->getNomUrl(1);
+ } elseif ($data['item'] == 'Donation') {
+ $don->id = $data['id'];
+ $don->ref = $data['ref'];
+ print $don->getNomUrl(1, 0, '', 0);
+ } elseif ($data['item'] == 'SocialContributions') {
+ $charge_sociales->id = $data['id'];
+ $charge_sociales->ref = $data['ref'];
+ print $charge_sociales->getNomUrl(1, 0, 0, 0, 0);
+ } elseif ($data['item'] == 'VariousPayment') {
+ $various_payment->id = $data['id'];
+ $various_payment->ref = $data['ref'];
+ print $various_payment->getNomUrl(1, '', 0, 0);
+ } elseif ($data['item'] == 'LoanPayment') {
+ $payment_loan->id = $data['id'];
+ $payment_loan->ref = $data['ref'];
+ print $payment_loan->getNomUrl(1, 0, 0, '', 0);
+ } else {
+ print $data['ref'];
}
- print ' ';
- } else {
- // Sort array by date ASC to calculate balance
+ print '';
- $totalET_debit = 0;
- $totalIT_debit = 0;
- $totalVAT_debit = 0;
- $totalET_credit = 0;
- $totalIT_credit = 0;
- $totalVAT_credit = 0;
-
- // Display array
- foreach ($TData as $data) {
- $html_class = '';
- //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
- //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
- print '';
-
- // Type
- print ''.$langs->trans($data['item']).' ';
-
- // Date
- print '';
- print dol_print_date($data['date'], 'day');
- print " \n";
-
- // Date due
- print '';
- print dol_print_date($data['date_due'], 'day');
- print " \n";
-
- // Ref
- print '';
-
- if ($data['item'] == 'Invoice') {
- $invoice->id = $data['id'];
- $invoice->ref = $data['ref'];
- $invoice->total_ht = $data['amount_ht'];
- $invoice->total_ttc = $data['amount_ttc'];
- $invoice->total_tva = $data['amount_vat'];
- $invoice->multicurrency_code = $data['currency'];
- print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
- } elseif ($data['item'] == 'SupplierInvoice') {
- $supplier_invoice->id = $data['id'];
- $supplier_invoice->ref = $data['ref'];
- $supplier_invoice->total_ht = $data['amount_ht'];
- $supplier_invoice->total_ttc = $data['amount_ttc'];
- $supplier_invoice->total_tva = $data['amount_vat'];
- $supplier_invoice->multicurrency_code = $data['currency'];
- print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
- } elseif ($data['item'] == 'ExpenseReport') {
- $expensereport->id = $data['id'];
- $expensereport->ref = $data['ref'];
- print $expensereport->getNomUrl(1, 0, 0, '', 0, 0);
- } elseif ($data['item'] == 'SalaryPayment') {
- $salary_payment->id = $data['id'];
- $salary_payment->ref = $data['ref'];
- print $salary_payment->getNomUrl(1);
- } elseif ($data['item'] == 'Donation') {
- $don->id = $data['id'];
- $don->ref = $data['ref'];
- print $don->getNomUrl(1, 0, '', 0);
- } elseif ($data['item'] == 'SocialContributions') {
- $charge_sociales->id = $data['id'];
- $charge_sociales->ref = $data['ref'];
- print $charge_sociales->getNomUrl(1, 0, 0, 0, 0);
- } elseif ($data['item'] == 'VariousPayment') {
- $various_payment->id = $data['id'];
- $various_payment->ref = $data['ref'];
- print $various_payment->getNomUrl(1, '', 0, 0);
- } elseif ($data['item'] == 'LoanPayment') {
- $payment_loan->id = $data['id'];
- $payment_loan->ref = $data['ref'];
- print $payment_loan->getNomUrl(1, 0, 0, '', 0);
- } else {
- print $data['ref'];
- }
- print ' ';
-
- // File link
- print '';
- if (!empty($data['files'])) {
- foreach ($data['files'] as $id => $filecursor) {
- print ''.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).' '.$formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name']).' ';
+ // File link
+ print ' ';
+ if (!empty($data['files'])) {
+ foreach ($data['files'] as $id => $filecursor) {
+ $tmppreview = $formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name'], 0);
+ if ($tmppreview) {
+ print $tmppreview;
}
+ $filename = ($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']);
+ print '';
+ if (empty($tmppreview)) {
+ print img_picto('', 'generic', '', false, 0, 0, '', 'pictonopreview pictofixedwidth paddingright');
+ }
+ print $filename;
+ print ' ';
}
- print " \n";
+ }
+ print "\n";
- // Paid
- print ''.$data['paid'].' ';
+ // Paid
+ print ''.($data['paid'] ? yn($data['paid']) : '').' ';
- // Total ET
- print ''.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))." \n";
- // Total IT
- print ''.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))." \n";
- // Total VAT
- print ''.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))." \n";
+ // Total ET
+ print ''.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))." \n";
+ // Total IT
+ print ''.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))." \n";
+ // Total VAT
+ print ''.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))." \n";
- print ''.dol_escape_htmltag($data['thirdparty_name'])." \n";
+ print ''.dol_escape_htmltag($data['thirdparty_name'])." \n";
- print ''.$data['thirdparty_code']." \n";
+ print ''.$data['thirdparty_code']." \n";
- print ''.$data['country_code']." \n";
+ print ''.$data['country_code']." \n";
- print ''.dol_escape_htmltag($data['vatnum'])." \n";
+ // VAT number
+ print ''.dol_escape_htmltag($data['vatnum'])." \n";
- if ($data['sens']) {
- $totalET_credit += $data['amount_ht'];
- $totalIT_credit += $data['amount_ttc'];
- $totalVAT_credit += $data['amount_vat'];
- } else {
- $totalET_debit -= $data['amount_ht'];
- $totalIT_debit -= $data['amount_ttc'];
- $totalVAT_debit -= $data['amount_vat'];
- }
-
- if (!empty($conf->multicurrency->enabled)) {
- print ''.$data['currency']." \n";
- }
-
- print " \n";
+ if ($data['sens']) {
+ $totalET_credit += $data['amount_ht'];
+ $totalIT_credit += $data['amount_ttc'];
+ $totalVAT_credit += $data['amount_vat'];
+ } else {
+ $totalET_debit -= $data['amount_ht'];
+ $totalIT_debit -= $data['amount_ttc'];
+ $totalVAT_debit -= $data['amount_vat'];
}
- // Total credits
- print '';
- print ''.$langs->trans('Total').' '.$langs->trans('Income').' ';
- print ''.price(price2num($totalET_credit, 'MT')).' ';
- print ''.price(price2num($totalIT_credit, 'MT')).' ';
- print ''.price(price2num($totalVAT_credit, 'MT')).' ';
- print ' ';
if (!empty($conf->multicurrency->enabled)) {
- print ' ';
- }
- print " \n";
- // Total debits
- print '';
- print ''.$langs->trans('Total').' '.$langs->trans('Outcome').' ';
- print ''.price(price2num($totalET_debit, 'MT')).' ';
- print ''.price(price2num($totalIT_debit, 'MT')).' ';
- print ''.price(price2num($totalVAT_debit, 'MT')).' ';
- print ' ';
- if (!empty($conf->multicurrency->enabled)) {
- print ' ';
- }
- print " \n";
- // Balance
- print '';
- print ''.$langs->trans('Total').' ';
- print ''.price(price2num($totalET_credit + $totalET_debit, 'MT')).' ';
- print ''.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).' ';
- print ''.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).' ';
- print ' ';
- if (!empty($conf->multicurrency->enabled)) {
- print ' ';
+ print ''.$data['currency']." \n";
}
+
print " \n";
}
+
+ // Total credits
+ print '';
+ print ''.$langs->trans('Total').' '.$langs->trans('Income').' ';
+ print ''.price(price2num($totalET_credit, 'MT')).' ';
+ print ''.price(price2num($totalIT_credit, 'MT')).' ';
+ print ''.price(price2num($totalVAT_credit, 'MT')).' ';
+ print ' ';
+ if (!empty($conf->multicurrency->enabled)) {
+ print ' ';
+ }
+ print " \n";
+ // Total debits
+ print '';
+ print ''.$langs->trans('Total').' '.$langs->trans('Outcome').' ';
+ print ''.price(price2num($totalET_debit, 'MT')).' ';
+ print ''.price(price2num($totalIT_debit, 'MT')).' ';
+ print ''.price(price2num($totalVAT_debit, 'MT')).' ';
+ print ' ';
+ if (!empty($conf->multicurrency->enabled)) {
+ print ' ';
+ }
+ print " \n";
+ // Balance
+ print '';
+ print ''.$langs->trans('Total').' ';
+ print ''.price(price2num($totalET_credit + $totalET_debit, 'MT')).' ';
+ print ''.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).' ';
+ print ''.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).' ';
+ print ' ';
+ if (!empty($conf->multicurrency->enabled)) {
+ print ' ';
+ }
+ print " \n";
}
+
print "
";
print '';
}
diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php
index 8893f91c2c2..05b30d69668 100644
--- a/htdocs/compta/bank/bankentries_list.php
+++ b/htdocs/compta/bank/bankentries_list.php
@@ -214,7 +214,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_thirdparty_user = '';
$search_num_releve = '';
$search_conciliated = '';
- $toselect = '';
+ $toselect = array();
$search_account = "";
if ($id > 0 || !empty($ref)) {
@@ -276,6 +276,9 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', '
if ($offset) {
$param .= '&offset='.urlencode($offset);
}
+ if ($limit) {
+ $param .= '&limit='.urlencode($limit);
+ }
if ($search_conciliated != '' && $search_conciliated != '-1') {
$param .= '&search_conciliated='.urlencode($search_conciliated);
}
@@ -980,21 +983,27 @@ if ($resql) {
$moreforfilter = '';
$moreforfilter .= '';
- $moreforfilter .= $langs->trans('DateOperationShort').' ';
+ $moreforfilter .= $langs->trans('DateOperationShort');
$moreforfilter .= ($conf->browser->layout == 'phone' ? '
' : ' ');
$moreforfilter .= '
';
- $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')).'
';
- //$moreforfilter .= ' - ';
- $moreforfilter .= '
'.$form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')).'
';
+ $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+ $moreforfilter .= '
';
+ $moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' ');
+ $moreforfilter .= '';
+ $moreforfilter .= $form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+ $moreforfilter .= '
';
$moreforfilter .= '';
$moreforfilter .= '';
- $moreforfilter .= $langs->trans('DateValueShort').' ';
+ $moreforfilter .= $langs->trans('DateValueShort');
$moreforfilter .= ($conf->browser->layout == 'phone' ? '
' : ' ');
$moreforfilter .= '
';
- $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')).'
';
- //$moreforfilter .= ' - ';
- $moreforfilter .= '
'.$form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')).'
';
+ $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+ $moreforfilter .= '
';
+ $moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' ');
+ $moreforfilter .= '';
+ $moreforfilter .= $form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+ $moreforfilter .= '
';
$moreforfilter .= '';
if (!empty($conf->categorie->enabled)) {
diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php
index f8cc88e1be4..495dd86f268 100644
--- a/htdocs/compta/bank/card.php
+++ b/htdocs/compta/bank/card.php
@@ -65,7 +65,8 @@ $hookmanager->initHooks(array('bankcard', 'globalcard'));
// Security check
$id = GETPOST("id", 'int') ? GETPOST("id", 'int') : GETPOST('ref', 'alpha');
-$fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid';
+$fieldid = GETPOST("id", 'int') ? 'rowid' : 'ref';
+
$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
@@ -724,7 +725,7 @@ if ($action == 'create') {
print '
';
if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT) {
- print '
';
+ //print '
';
print '';
@@ -777,13 +778,14 @@ if ($action == 'create') {
print '';
if ($conf->prelevement->enabled) {
- print ''.$langs->trans("ICS").' ('.$langs->trans("StandingOrder").') ';
+ print ''.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').' ';
print ''.$object->ics.' ';
print ' ';
}
+ // TODO ICS is not used with bank transfer !
if ($conf->paymentbybanktransfer->enabled) {
- print ''.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").') ';
+ print ''.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').' ';
print ''.$object->ics_transfer.' ';
print ' ';
@@ -1081,12 +1083,12 @@ if ($action == 'create') {
print ' ';
if ($conf->prelevement->enabled) {
- print ''.$langs->trans("ICS").' ('.$langs->trans("StandingOrder").') ';
+ print ''.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').' ';
print ' ';
}
if ($conf->paymentbybanktransfer->enabled) {
- print ''.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").') ';
+ print ''.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').' ';
print ' ';
print ''.$langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation").' ';
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index f6875521617..429d7c704c8 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -519,9 +519,10 @@ class Account extends CommonObject
* @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on.
* @param int $datev Date value
* @param string $num_releve Label of bank receipt for reconciliation
+ * @param float $amount_main_currency Amount
* @return int Rowid of added entry, <0 if KO
*/
- public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null, $num_releve = '')
+ public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null, $num_releve = '', $amount_main_currency = null)
{
// Deprecation warning
if (is_numeric($oper)) {
@@ -579,6 +580,7 @@ class Account extends CommonObject
$accline->datev = $datev;
$accline->label = $label;
$accline->amount = $amount;
+ $accline->amount_main_currency = $amount_main_currency;
$accline->fk_user_author = $user->id;
$accline->fk_account = $this->id;
$accline->fk_type = $oper;
@@ -866,7 +868,7 @@ class Account extends CommonObject
if (!$error && !$notrigger) {
// Call trigger
- $result = $this->call_trigger('BANKACCOUNT_UPDATE', $user);
+ $result = $this->call_trigger('BANKACCOUNT_MODIFY', $user);
if ($result < 0) {
$error++;
}
@@ -1453,9 +1455,13 @@ class Account extends CommonObject
// Call function to check BAN
- if (!checkIbanForAccount($this) || !checkSwiftForAccount($this)) {
+ if (!checkIbanForAccount($this)) {
$this->error_number = 12;
- $this->error_message = 'IBANSWIFTControlError';
+ $this->error_message = 'IBANNotValid';
+ }
+ if (!checkSwiftForAccount($this)) {
+ $this->error_number = 12;
+ $this->error_message = 'SwiftNotValid';
}
/*if (! checkBanForAccount($this))
{
@@ -1728,7 +1734,7 @@ class Account extends CommonObject
if ($dbs->query($sql)) {
return true;
} else {
- //if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B.
+ //if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdparty and B-C on old one, we must get A-B-C after merge. Not A-B.
//$this->errors = $dbs->lasterror();
return false;
}
@@ -1797,7 +1803,8 @@ class AccountLine extends CommonObject
*/
public $datev;
- public $amount;
+ public $amount; /* Amount of payment in the bank account currency */
+ public $amount_main_currency; /* Amount in the currency of company if bank account use another currency */
/**
* @var int ID
@@ -1958,6 +1965,7 @@ class AccountLine extends CommonObject
$sql .= ", datev";
$sql .= ", label";
$sql .= ", amount";
+ $sql .= ", amount_main_currency";
$sql .= ", fk_user_author";
$sql .= ", num_chq";
$sql .= ", fk_account";
@@ -1972,7 +1980,8 @@ class AccountLine extends CommonObject
$sql .= ", '".$this->db->idate($this->datev)."'";
$sql .= ", '".$this->db->escape($this->label)."'";
$sql .= ", ".price2num($this->amount);
- $sql .= ", ".($this->fk_user_author > 0 ? $this->fk_user_author : "null");
+ $sql .= ", ".(empty($this->amount_main_currency) ? "NULL" : price2num($this->amount_main_currency));
+ $sql .= ", ".($this->fk_user_author > 0 ? ((int) $this->fk_user_author) : "null");
$sql .= ", ".($this->num_chq ? "'".$this->db->escape($this->num_chq)."'" : "null");
$sql .= ", '".$this->db->escape($this->fk_account)."'";
$sql .= ", '".$this->db->escape($this->fk_type)."'";
diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php
index 9b9781b31a0..19b47430fad 100644
--- a/htdocs/compta/bank/list.php
+++ b/htdocs/compta/bank/list.php
@@ -587,10 +587,14 @@ foreach ($accounts as $key => $type) {
// Accountancy journal
if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) {
print '';
- if (!empty($conf->accounting->enabled) && !empty($objecttmp->fk_accountancy_journal)) {
- $accountingjournal = new AccountingJournal($db);
- $accountingjournal->fetch($objecttmp->fk_accountancy_journal);
- print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
+ if (!empty($conf->accounting->enabled)) {
+ if (empty($objecttmp->fk_accountancy_journal)) {
+ print img_warning($langs->trans("Mandatory"));
+ } else {
+ $accountingjournal = new AccountingJournal($db);
+ $accountingjournal->fetch($objecttmp->fk_accountancy_journal);
+ print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
+ }
} else {
print '';
}
diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php
index 0003570fd02..ab4b24e3889 100644
--- a/htdocs/compta/bank/various_payment/card.php
+++ b/htdocs/compta/bank/various_payment/card.php
@@ -179,7 +179,7 @@ if (empty($reshook)) {
$action = 'create';
}
- if ($action == 'delete') {
+ if ($action == 'confirm_delete' && $confirm == 'yes') {
$result = $object->fetch($id);
if ($object->rappro == 0) {
@@ -543,6 +543,12 @@ if ($id) {
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 350);
}
+ // Confirmation of the removal of the Various Payment
+ if ($action == 'delete') {
+ $text = $langs->trans('ConfirmDeleteVariousPayment');
+ print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteVariousPayment'), $text, 'confirm_delete', '', '', 2);
+ }
+
print dol_get_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto);
$morehtmlref = '';
diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php
index 7822819c06a..2315f12757a 100644
--- a/htdocs/compta/cashcontrol/cashcontrol_list.php
+++ b/htdocs/compta/cashcontrol/cashcontrol_list.php
@@ -165,7 +165,7 @@ if (empty($reshook)) {
$search[$key.'_dtend'] = '';
}
}
- $toselect = '';
+ $toselect = array();
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php
index 6116db707e2..6300e387067 100644
--- a/htdocs/compta/facture/card-rec.php
+++ b/htdocs/compta/facture/card-rec.php
@@ -641,7 +641,7 @@ if (empty($reshook)) {
setEventMessages($mesg, null, 'errors');
} else {
// Insert line
- $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice);
+ $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, -1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice);
if ($result > 0) {
// Define output language and generate document
@@ -967,7 +967,7 @@ if ($action == 'create') {
// Title
print '
'.$langs->trans("Title").' ';
- print ' ';
+ print ' ';
print ' ';
// Third party
@@ -1034,21 +1034,11 @@ if ($action == 'create') {
// Payment mode
print "
".$langs->trans("PaymentMode")." ";
+ print img_picto('', 'payment', 'class="pictofixedwidth"');
print $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 0, 0, 1, '', 1);
//$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', '', 1);
print " ";
- // Project
- if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) {
- $projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project;
- $langs->load('projects');
- print '
'.$langs->trans('Project').' ';
- print img_picto('', 'project');
- $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
- print ' thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').' ';
- print ' ';
- }
-
// Bank account
if ($object->fk_account > 0) {
print "
".$langs->trans('BankAccount')." ";
@@ -1056,10 +1046,22 @@ if ($action == 'create') {
print " ";
}
+ // Project
+ if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) {
+ $projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project;
+ $langs->load('projects');
+ print '
'.$langs->trans('Project').' ';
+ print img_picto('', 'project', 'class="pictofixedwidth"');
+ $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
+ print ' thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').' ';
+ print ' ';
+ }
+
// Model pdf
print "
".$langs->trans('Model')." ";
include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
$list = ModelePDFFactures::liste_modeles($db);
+ print img_picto('', 'generic', 'class="pictofixedwidth"');
print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF);
print " ";
@@ -1605,19 +1607,19 @@ if ($action == 'create') {
// Lines
- print '