From e7056a9ade7e88414bc688e7d21893306dac7f26 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Thu, 12 Mar 2020 11:00:17 +0100 Subject: [PATCH 1/4] NEW add a parameter to group same product --- htdocs/langs/en_US/cashdesk.lang | 1 + htdocs/langs/fr_FR/cashdesk.lang | 1 + htdocs/takepos/admin/setup.php | 7 +++++++ htdocs/takepos/invoice.php | 18 +++++++++++++++++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index d4355566872..ef939b31258 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -92,3 +92,4 @@ PrintMethod=Print method ReceiptPrinterMethodDescription=Powerful method with a lot of parameters. Full customizable with templates. Cannot print from the cloud. ByTerminal=By terminal TakeposNumpadUsePaymentIcon=Use payment icon on numpad +TakeposGroupSameProduct=Group same products lines diff --git a/htdocs/langs/fr_FR/cashdesk.lang b/htdocs/langs/fr_FR/cashdesk.lang index 03ca0155daa..dc4e47cb868 100644 --- a/htdocs/langs/fr_FR/cashdesk.lang +++ b/htdocs/langs/fr_FR/cashdesk.lang @@ -83,3 +83,4 @@ ProductSupplements=Suppléments de produit SupplementCategory=Catégorie des suppléments SortProductField=Champ pour le tri des produits TakeposNumpadUsePaymentIcon=Utilisation d'icônes sur les touches des modes de règlement du pavé numérique +TakeposGroupSameProduct=Regrouper les mêmes lignes de produits diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index fce4d6d324f..830ca9154f2 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -76,6 +76,7 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_SORTPRODUCTFIELD", GETPOST('TAKEPOS_SORTPRODUCTFIELD', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TAKEPOS_GROUP_SAME_PRODUCT', GETPOST('TAKEPOS_GROUP_SAME_PRODUCT', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_COLOR_THEME", GETPOST('TAKEPOS_COLOR_THEME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity); @@ -179,6 +180,12 @@ $array = array('rowid' => 'ID', 'ref' => 'Ref', 'label' => 'Label', 'datec' => ' print $form->selectarray('TAKEPOS_SORTPRODUCTFIELD', $array, (empty($conf->global->TAKEPOS_SORTPRODUCTFIELD) ? 'rowid' : $conf->global->TAKEPOS_SORTPRODUCTFIELD), 0, 0, 0, '', 1); print "\n"; +print ''; +print $langs->trans('TakeposGroupSameProduct'); +print ''; +print ajax_constantonoff("TAKEPOS_GROUP_SAME_PRODUCT", array(), $conf->entity, 0, 0, 1, 0); +print "\n"; + $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 60854bf2407..d80e593f3cb 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -318,7 +318,23 @@ if ($action == "addline") } } - $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, $parent_line, null, 0, '', 0, 100, '', null, 0); + $idoflineadded = 0; + if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT)) { + foreach ($invoice->lines as $line) { + if ($line->product_ref == $prod->ref) { + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty+1, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + if ($result < 0) { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } else { + $idoflineadded = $line->id; + } + break; + } + } + } + if ($idoflineadded <= 0) { + $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, $parent_line, null, 0, '', 0, 100, '', null, 0); + } $invoice->fetch($placeid); } From 033f7963980fc9c6232cf074f13397b67916db67 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 17 Mar 2020 14:51:48 +0100 Subject: [PATCH 2/4] Work on split module fournisseur --- htdocs/admin/dict.php | 6 +++--- htdocs/admin/fckeditor.php | 2 +- htdocs/admin/mails_templates.php | 4 ++-- htdocs/admin/stock.php | 4 ++-- htdocs/core/lib/company.lib.php | 3 ++- htdocs/core/modules/modBanque.class.php | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index d634f547ff9..949037b92e1 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -437,15 +437,15 @@ $tabcond[8] = !empty($conf->societe->enabled); $tabcond[9] = true; $tabcond[10] = true; $tabcond[11] = (!empty($conf->societe->enabled)); -$tabcond[12] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled)); -$tabcond[13] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled)); +$tabcond[12] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled) || !empty($conf->supplier_order->enabled)); +$tabcond[13] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled) || !empty($conf->supplier_order->enabled)); $tabcond[14] = (!empty($conf->product->enabled) && (!empty($conf->ecotax->enabled) || !empty($conf->global->MAIN_SHOW_ECOTAX_DICTIONNARY))); $tabcond[15] = true; $tabcond[16] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)); $tabcond[17] = (!empty($conf->deplacement->enabled) || !empty($conf->expensereport->enabled)); $tabcond[18] = !empty($conf->expedition->enabled) || !empty($conf->reception->enabled); $tabcond[19] = !empty($conf->societe->enabled); -$tabcond[20] = !empty($conf->fournisseur->enabled); +$tabcond[20]= (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled)); $tabcond[21] = !empty($conf->propal->enabled); $tabcond[22] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled)); $tabcond[23] = true; diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index efe8ca1117d..869a08047ec 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -57,7 +57,7 @@ $modules = array( $conditions = array( 'SOCIETE' => 1, 'PRODUCTDESC' => (! empty($conf->product->enabled) || ! empty($conf->service->enabled)), -'DETAILS' => (! empty($conf->facture->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) || ! empty($conf->supplier_proposal->enabled) || ! empty($conf->fournisseur->enabled)), +'DETAILS' => (! empty($conf->facture->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) || ! empty($conf->supplier_proposal->enabled) || ! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled) || ! empty($conf->supplier_invoice->enabled)), 'USERSIGN' => 1, 'MAILING' => ! empty($conf->mailing->enabled), 'MAIL' => (! empty($conf->facture->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled)), diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index bb5fd72ec29..9969acc5415 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -160,8 +160,8 @@ if ($conf->expedition->enabled) $elementList['shipping_send'] = $langs->t if ($conf->reception->enabled) $elementList['reception_send'] = $langs->trans('MailToSendReception'); if ($conf->ficheinter->enabled) $elementList['fichinter_send'] = $langs->trans('MailToSendIntervention'); if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send'] = $langs->trans('MailToSendSupplierRequestForQuotation'); -if ($conf->fournisseur->enabled) $elementList['order_supplier_send'] = $langs->trans('MailToSendSupplierOrder'); -if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send'] = $langs->trans('MailToSendSupplierInvoice'); +if ($conf->fournisseur->enabled && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || $conf->supplier_order->enabled) $elementList['order_supplier_send'] = $langs->trans('MailToSendSupplierOrder'); +if ($conf->fournisseur->enabled && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || $conf->supplier_invoice->enabled) $elementList['invoice_supplier_send'] = $langs->trans('MailToSendSupplierInvoice'); if ($conf->societe->enabled) $elementList['thirdparty'] = $langs->trans('MailToThirdparty'); if ($conf->adherent->enabled) $elementList['member'] = $langs->trans('MailToMember'); if ($conf->contrat->enabled) $elementList['contract'] = $langs->trans('MailToSendContract'); diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index f1cbea504d3..0b6987b1a9f 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -213,7 +213,7 @@ $found=0; print ''; print ''.$langs->trans("ReStockOnBill").''; print ''; -if (! empty($conf->fournisseur->enabled)) +if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled) || ! empty($conf->supplier_invoice->enabled)) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL'); @@ -234,7 +234,7 @@ $found++; print ''; print ''.$langs->trans("ReStockOnValidateOrder").''; print ''; -if (! empty($conf->fournisseur->enabled)) +if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled) || ! empty($conf->supplier_invoice->enabled)) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index a3771d53cff..0ee3f32e015 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -104,7 +104,8 @@ function societe_prepare_head(Societe $object) $h++; } } - if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) + if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) $supplier_module_enabled=1; + if ($supplier_module_enabled==1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id; $head[$h][1] = $langs->trans("Supplier"); diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 6448dcd74ef..21e636364e3 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -161,7 +161,7 @@ class modBanque extends DolibarrModules "s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company" ); $this->export_special_array[$r]=array('-b.amount'=>'NULLIFNEG','b.amount'=>'NULLIFNEG'); - if (empty($conf->fournisseur->enabled)) + if (empty($conf->fournisseur->enabled) && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || empty($conf->supplier_order->enabled) || empty($conf->supplier_invoice->enabled)) { unset($this->export_fields_array[$r]['s.code_compta_fournisseur']); unset($this->export_entities_array[$r]['s.code_compta_fournisseur']); From a6227aeb6a0b5f5265c11b01d982dc08b3df67c5 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 19 Mar 2020 11:53:42 +0100 Subject: [PATCH 3/4] FIX: Load the translation file for extrafields --- htdocs/core/class/extrafields.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index a9b908203fe..b5ac448be5d 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -848,7 +848,7 @@ class ExtraFields public function fetch_name_optionals_label($elementtype, $forceload = false) { // phpcs:enable - global $conf; + global $langs, $conf; if (empty($elementtype)) return array(); @@ -912,6 +912,11 @@ class ExtraFields $array_name_label[$tab->name] = $tab->label; } + if (! empty($tab->langs)) + { + $langs->load($tab->langs); + } + // Old usage $this->attribute_type[$tab->name] = $tab->type; $this->attribute_label[$tab->name] = $tab->label; @@ -1944,6 +1949,10 @@ class ExtraFields { $align = "right"; } + elseif ($type == 'price') + { + $align="right"; + } elseif ($type == 'double') { $align = "right"; From 5ffc57f3f077a1f008d6d4dfcf97e94cd99e1bbc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Mar 2020 10:05:08 +0100 Subject: [PATCH 4/4] Update extrafields.class.php --- htdocs/core/class/extrafields.class.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index b5ac448be5d..94504686718 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -848,7 +848,7 @@ class ExtraFields public function fetch_name_optionals_label($elementtype, $forceload = false) { // phpcs:enable - global $langs, $conf; + global $conf; if (empty($elementtype)) return array(); @@ -912,11 +912,6 @@ class ExtraFields $array_name_label[$tab->name] = $tab->label; } - if (! empty($tab->langs)) - { - $langs->load($tab->langs); - } - // Old usage $this->attribute_type[$tab->name] = $tab->type; $this->attribute_label[$tab->name] = $tab->label;