From 196156a21eb0974a9459fe45a4599cc0b4952b2a Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 13 Apr 2017 16:35:29 +0200 Subject: [PATCH 01/34] fix setEventMessages error insteads of errors --- htdocs/compta/bank/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index dcc0fc85ecc..5afc6c3583b 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -117,7 +117,7 @@ if ($action == 'add') if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) { - setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error'); + setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors'); $action='create'; // Force chargement page en mode creation $error++; } From 24962863744aad5a3062c8690ec6206d469b24d9 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 14 Apr 2017 12:27:53 +0200 Subject: [PATCH 02/34] fix :missing mainmenu and leftmenu into accoutancy menu descriptor --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index d3e777b13ba..b981686d7c7 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -791,7 +791,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->facture->enabled)) { $langs->load("bills"); - $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire); + $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire, '', $mainmenu, 'customers_bills'); $newmenu->add("/compta/facture.php?action=create",$langs->trans("NewBill"),1,$user->rights->facture->creer); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("List"),1,$user->rights->facture->lire); From 6c5b329dd17bbb69c3089d017d72b6ee6354e948 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 14 Apr 2017 14:51:39 +0200 Subject: [PATCH 03/34] Fix : display bank on supplier payment as on customer payment --- htdocs/fourn/paiement/card.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index 3b93eb85cc9..9d030035d76 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -227,9 +227,8 @@ if ($result > 0) print ''.$langs->trans('BankAccount').''; print ''; $accountstatic=new Account($db); - $accountstatic->id=$bankline->fk_account; - $accountstatic->label=$bankline->bank_account_ref.' - '.$bankline->bank_account_label; - print $accountstatic->getNomUrl(0); + $accountstatic->fetch($bankline->fk_account); + print $accountstatic->getNomUrl(1); print ''; print ''; } From 402924f6d7b6d073957e06321bc49e83638f2d5d Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 14 Apr 2017 15:12:32 +0200 Subject: [PATCH 04/34] Fix : no origin on stock mvmt when order set back to draft --- htdocs/commande/class/commande.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index e1b59f34772..462ba4756c5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -464,6 +464,7 @@ class Commande extends CommonOrder if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; // We increment stock of product (and sub-products) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr",$this->ref)); if ($result < 0) { $error++; $this->error=$mouvP->error; break; } From 006ad4cef82264d5d1044709dbc058c9a3cdc20f Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Sat, 15 Apr 2017 20:04:45 +0200 Subject: [PATCH 05/34] FIX #6718 Bug: Discount amount is not locally formatted in CommonObject View --- htdocs/core/lib/functions2.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index bb34806965a..07d7509c80b 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -5,6 +5,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2015-2016 Raphaël Doursenaud + * Copyright (C) 2017 Juanjo Menent * * 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 @@ -1439,7 +1440,7 @@ function dol_print_reduction($reduction,$langs) } else { - $string = $reduction.'%'; + $string = price($reduction).'%'; } return $string; From e1ea6e2b534fd8d634aec9ece49ff2738140ebcb Mon Sep 17 00:00:00 2001 From: rassakali Date: Sun, 16 Apr 2017 12:04:36 +0200 Subject: [PATCH 06/34] Update card.php --- htdocs/adherents/subscription/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index c8f68d2151c..5cb10e31e6d 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -145,7 +145,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent- $result=$object->delete($user); if ($result > 0) { - header("Location: card_subscriptions.php?rowid=".$object->fk_adherent); + header("Location: ".DOL_URL_ROOT."/adherents/card.php?rowid=".$object->fk_adherent); exit; } else From 82f9555c6b96fe4298064e1d2584a2c688f6586a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2017 01:35:58 +0200 Subject: [PATCH 07/34] Translation --- htdocs/langs/en_US/mails.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 61dddb46691..1c10623a75b 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -35,7 +35,7 @@ MailingStatusSentPartialy=Sent partialy MailingStatusSentCompletely=Sent completely MailingStatusError=Error MailingStatusNotSent=Not sent -MailSuccessfulySent=Email successfully accepted for delivery (from %s to %s) +MailSuccessfulySent=Email (from %s to %s) successfully accepted for delivery MailingSuccessfullyValidated=EMailing successfully validated MailUnsubcribe=Unsubscribe MailingStatusNotContact=Don't contact anymore From d89a89f8ea5730171c1b84ff3b369d0d44c9ec43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2017 17:03:34 +0200 Subject: [PATCH 08/34] Fix error message --- htdocs/expedition/card.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 29f2b7fab48..0077338aae5 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1246,8 +1246,11 @@ if ($action == 'create') print ''; if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if ($warehouseObject) + $warehouse_selected_id = GETPOST('entrepot_id','int'); + if ($warehouse_selected_id > 0) { + $warehouseObject=new Entrepot($db); + $warehouseObject->fetch($warehouse_selected_id); print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->libelle); } else From cfc31e91e87064cf73931e18e3ff496da7a2ce27 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2017 18:13:43 +0200 Subject: [PATCH 09/34] FIX overwrapping of weight/volume on rouget template --- .../expedition/doc/pdf_rouget.modules.php | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index dab925eef1d..d1697b767bd 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -69,19 +69,18 @@ class pdf_rouget extends ModelePdfExpedition // Define position of columns $this->posxdesc=$this->marge_gauche+1; - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 76; + $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78; $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56; $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28; $this->posxpuht=$this->page_largeur - $this->marge_droite; - if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { + if (!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 130; - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 100; - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 70; + $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; + $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; + $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; $this->posxpuht=$this->page_largeur - $this->marge_droite - 40; $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20; - } $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images @@ -344,7 +343,7 @@ class pdf_rouget extends ModelePdfExpedition // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); - + $tab_height = $tab_height - $height_note; $tab_top = $nexY+6; } @@ -459,16 +458,17 @@ class pdf_rouget extends ModelePdfExpedition $weighttxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { - $weighttxt=$object->lines[$i]->weight*$object->lines[$i]->qty_shipped.' '.measuring_units_string($object->lines[$i]->weight_units,"weight"); + $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight"); } $voltxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { - $voltxt=$object->lines[$i]->volume*$object->lines[$i]->qty_shipped.' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume"); + $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume"); } - - $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?', ':'').$voltxt,'','C'); - + + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt, 0, 0, false, true, 'C'); + //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt,'','C'); + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->SetXY($this->posxqtyordered, $curY); @@ -479,27 +479,27 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C'); if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) -{ + { $pdf->SetXY($this->posxpuht, $curY); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R'); $pdf->SetXY($this->posxtotalht, $curY); $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R'); - } + $nexY+=3; + if ($weighttxt && $voltxt) $nexY+=2; + // Add line if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Passe espace entre les lignes - // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { @@ -650,7 +650,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); - if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); @@ -658,20 +658,20 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); - } + } // Total Weight if ($totalWeighttoshow) { - $pdf->SetXY($col2x-20, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2+20, $tab2_hl, $totalWeighttoshow, 0, 'R', 1); + $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); $index++; } if ($totalVolumetoshow) { - $pdf->SetXY($col2x-20, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2+20, $tab2_hl, $totalVolumetoshow, 0, 'R', 1); + $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); $index++; } @@ -949,6 +949,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFillColor(230,230,230); $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); $pdf->SetTextColor(0,0,60); + $pdf->SetFillColor(255,255,255); // Show sender name $pdf->SetXY($posx+2,$posy+3); From fbdfbed02c0a77175846139c31ba5cc67e472f63 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Apr 2017 02:44:38 +0200 Subject: [PATCH 10/34] Add code to prepare a generic payment solution --- htdocs/public/payment/index.php | 28 + htdocs/public/payment/newpayment.php | 1002 ++++++++++++++++++++++++++ htdocs/public/payment/paymentko.php | 146 ++++ htdocs/public/payment/paymentok.php | 308 ++++++++ 4 files changed, 1484 insertions(+) create mode 100644 htdocs/public/payment/index.php create mode 100644 htdocs/public/payment/newpayment.php create mode 100644 htdocs/public/payment/paymentko.php create mode 100644 htdocs/public/payment/paymentok.php diff --git a/htdocs/public/payment/index.php b/htdocs/public/payment/index.php new file mode 100644 index 00000000000..cc491b860d3 --- /dev/null +++ b/htdocs/public/payment/index.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/public/payment/index.php + * \ingroup core + * \brief A redirect page to an error + * \author Laurent Destailleur + */ + +require '../../master.inc.php'; + +header("Location: ".DOL_URL_ROOT.'/public/error-404.php'); + diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php new file mode 100644 index 00000000000..4c4b6863aaa --- /dev/null +++ b/htdocs/public/payment/newpayment.php @@ -0,0 +1,1002 @@ + + * Copyright (C) 2006-2012 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * For test: https://developer.paypal.com/ + */ + +/** + * \file htdocs/public/payment/newpayment.php + * \ingroup core + * \brief File to offer a way to make a payment for a particular Dolibarr entity + * \author Laurent Destailleur + */ + +define("NOLOGIN",1); // This means this output page does not require to be logged. +define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) define("DOLENTITY", $entity); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + +// Security check +//if (empty($conf->paypal->enabled)) accessforbidden('',0,0,1); + +$langs->load("main"); +$langs->load("other"); +$langs->load("dict"); +$langs->load("bills"); +$langs->load("companies"); +$langs->load("errors"); + +// Input are: +// type ('invoice','order','contractline'), +// id (object id), +// amount (required if id is empty), +// tag (a free text, required if type is empty) +// currency (iso code) + +$suffix=GETPOST("suffix",'alpha'); +$amount=price2num(GETPOST("amount")); +if (! GETPOST("currency",'alpha')) $currency=$conf->currency; +else $currency=GETPOST("currency",'alpha'); + +if (! GETPOST("action")) +{ + if (! GETPOST("amount") && ! GETPOST("source")) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - amount or source"); + exit; + } + if (is_numeric($amount) && ! GETPOST("tag") && ! GETPOST("source")) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - tag or source"); + exit; + } + if (GETPOST("source") && ! GETPOST("ref")) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - ref"); + exit; + } +} + +// Define $urlwithroot +//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + +$urlok=$urlwithroot.'/public/payment/paymentok.php?'; +$urlko=$urlwithroot.'/public/payment/paymentko.php?'; + +// Complete urls for post treatment +$SOURCE=GETPOST("source",'alpha'); +$ref=$REF=GETPOST('ref','alpha'); +$TAG=GETPOST("tag",'alpha'); +$FULLTAG=GETPOST("fulltag",'alpha'); // fulltag is tag with more informations +$SECUREKEY=GETPOST("securekey"); // Secure key + +if (! empty($SOURCE)) +{ + $urlok.='source='.urlencode($SOURCE).'&'; + $urlko.='source='.urlencode($SOURCE).'&'; +} +if (! empty($REF)) +{ + $urlok.='ref='.urlencode($REF).'&'; + $urlko.='ref='.urlencode($REF).'&'; +} +if (! empty($TAG)) +{ + $urlok.='tag='.urlencode($TAG).'&'; + $urlko.='tag='.urlencode($TAG).'&'; +} +if (! empty($FULLTAG)) +{ + $urlok.='fulltag='.urlencode($FULLTAG).'&'; + $urlko.='fulltag='.urlencode($FULLTAG).'&'; +} +if (! empty($SECUREKEY)) +{ + $urlok.='securekey='.urlencode($SECUREKEY).'&'; + $urlko.='securekey='.urlencode($SECUREKEY).'&'; +} +if (! empty($entity)) +{ + $urlok.='entity='.urlencode($entity).'&'; + $urlko.='entity='.urlencode($entity).'&'; +} +$urlok=preg_replace('/&$/','',$urlok); // Remove last & +$urlko=preg_replace('/&$/','',$urlko); // Remove last & + +$paymentmethod=array(); + +// Check parameters +if (! empty($conf->paypal->enabled)) +{ + $langs->load("paypal"); + + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; + + $PAYPAL_API_OK=""; + if ($urlok) $PAYPAL_API_OK=$urlok; + $PAYPAL_API_KO=""; + if ($urlko) $PAYPAL_API_KO=$urlko; + if (empty($PAYPAL_API_USER)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_USER not defined"); + return -1; + } + if (empty($PAYPAL_API_PASSWORD)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_PASSWORD not defined"); + return -1; + } + if (empty($PAYPAL_API_SIGNATURE)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE not defined"); + return -1; + } + + // Check security token + $valid=true; + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) + { + if ($SOURCE && $REF) $token = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $SOURCE . $REF, 2); // Use the source in the hash to avoid duplicates if the references are identical + else $token = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + } + else + { + $token = $conf->global->PAYPAL_SECURITY_TOKEN; + } + if ($SECUREKEY != $token) $valid=false; + + if (! $valid) + { + print '
Bad value for key.
'; + //print 'SECUREKEY='.$SECUREKEY.' token='.$token.' valid='.$valid; + exit; + } + else + { + $paymentmethod[]='paypal'; + } + } +} +if (! empty($conf->paybox->enabled)) +{ + $langs->load("paybox"); + +} +// TODO Add check of other payment mode + + +if (empty($paymentmethod)) accessforbidden('', 0, 0, 1); + + + +/* + * Actions + */ + +if (GETPOST("action") == 'dopayment') +{ + if (GETPOST('paymentmethod') == 'paypal') + { + $PAYPAL_API_PRICE=price2num(GETPOST("newamount"),'MT'); + $PAYPAL_PAYMENT_TYPE='Sale'; + + $shipToName=GETPOST("shipToName"); + $shipToStreet=GETPOST("shipToStreet"); + $shipToCity=GETPOST("shipToCity"); + $shipToState=GETPOST("shipToState"); + $shipToCountryCode=GETPOST("shipToCountryCode"); + $shipToZip=GETPOST("shipToZip"); + $shipToStreet2=GETPOST("shipToStreet2"); + $phoneNum=GETPOST("phoneNum"); + $email=GETPOST("email"); + $desc=GETPOST("desc"); + + $mesg=''; + if (empty($PAYPAL_API_PRICE) || ! is_numeric($PAYPAL_API_PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); + //elseif (empty($EMAIL)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); + //elseif (! isValidEMail($EMAIL)) $mesg=$langs->trans("ErrorBadEMail",$EMAIL); + elseif (empty($FULLTAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); + + //var_dump($_POST); + if (empty($mesg)) + { + dol_syslog("newpayment.php call paypal api and do redirect", LOG_DEBUG); + + // Other + $PAYPAL_API_DEVISE="USD"; + //if ($currency == 'EUR') $PAYPAL_API_DEVISE="EUR"; + //if ($currency == 'USD') $PAYPAL_API_DEVISE="USD"; + if (! empty($currency)) $PAYPAL_API_DEVISE=$currency; + + dol_syslog("Submit Paypal form", LOG_DEBUG); + dol_syslog("PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG); + //dol_syslog("PAYPAL_API_PASSWORD: $PAYPAL_API_PASSWORD", LOG_DEBUG); // No password into log files + dol_syslog("PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG); + dol_syslog("PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", LOG_DEBUG); + dol_syslog("PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG); + dol_syslog("PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG); + dol_syslog("PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG); + dol_syslog("PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG); + dol_syslog("shipToName: $shipToName", LOG_DEBUG); + dol_syslog("shipToStreet: $shipToStreet", LOG_DEBUG); + dol_syslog("shipToCity: $shipToCity", LOG_DEBUG); + dol_syslog("shipToState: $shipToState", LOG_DEBUG); + dol_syslog("shipToCountryCode: $shipToCountryCode", LOG_DEBUG); + dol_syslog("shipToZip: $shipToZip", LOG_DEBUG); + dol_syslog("shipToStreet2: $shipToStreet2", LOG_DEBUG); + dol_syslog("phoneNum: $phoneNum", LOG_DEBUG); + dol_syslog("email: $email", LOG_DEBUG); + dol_syslog("desc: $desc", LOG_DEBUG); + + dol_syslog("SCRIPT_URI: ".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG); // If defined script uri must match domain of PAYPAL_API_OK and PAYPAL_API_KO + //$_SESSION["PaymentType"]=$PAYPAL_PAYMENT_TYPE; + //$_SESSION["currencyCodeType"]=$PAYPAL_API_DEVISE; + //$_SESSION["Payment_Amount"]=$PAYPAL_API_PRICE; + + // A redirect is added if API call successfull + print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); + + exit; + } + } +} + + +/* + * View + */ + +llxHeaderPaypal($langs->trans("PaymentForm")); + +if (! empty($conf->paypal->enabled)) +{ + if (! empty($PAYPAL_API_SANDBOX)) + { + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning'); + } + + // Common variables + $creditor=$mysoc->name; + $paramcreditor='PAYPAL_CREDITOR_'.$suffix; + if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor; + else if (! empty($conf->global->PAYPAL_CREDITOR)) $creditor=$conf->global->PAYPAL_CREDITOR; +} + +print ''."\n"; +print '
'."\n"; +print '
'."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''; +print "\n"; +print ''."\n"; +if (! empty($conf->paypal->enabled)) +{ + print ''."\n"; + print ''."\n"; + print ''."\n"; +} +print ''."\n"; +print ''."\n"; +print "\n"; + +print ''."\n"; + +// Show logo (search order: logo defined by PAYBOX_LOGO_suffix, then PAYBOX_LOGO, then small company logo, large company logo, theme logo, common logo) +$width=0; +// Define logo and logosmall +$logosmall=$mysoc->logo_small; +$logo=$mysoc->logo; +$paramlogo='PAYMENT_LOGO_'.$suffix; +if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo; +else if (! empty($conf->global->PAYMENT_LOGO)) $logosmall=$conf->global->PAYBOX_LOGO; +//print ''."\n"; +// Define urllogo +$urllogo=''; +if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) +{ + $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('thumbs/'.$logosmall); +} +elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) +{ + $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode($logo); + $width=96; +} +// Output html code for logo +if ($urllogo) +{ + print ''; + print ''; + print ''."\n"; +} + +// Output introduction text +$text=''; +if (! empty($conf->global->PAYPAL_NEWFORM_TEXT)) +{ + $langs->load("members"); + if (preg_match('/^\((.*)\)$/',$conf->global->PAYPAL_NEWFORM_TEXT,$reg)) $text.=$langs->trans($reg[1])."
\n"; + else $text.=$conf->global->PAYPAL_NEWFORM_TEXT."
\n"; + $text=''."\n"; +} +if (empty($text)) +{ + $text.=''."\n"; + $text.=''."\n"; +} +print $text; + +// Output payment summary form +print ''."\n"; + +print '

'.$text.'

'.$langs->trans("WelcomeOnPaymentPage").'

'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'

'; +print ''; +print ''."\n"; + +$found=false; +$error=0; +$var=false; + +// Free payment +if (! GETPOST("source") && $valid) +{ + $found=true; + $tag=GETPOST("tag"); + $fulltag=$tag; + + // Creditor + + print ''."\n"; + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum + // as they don't exists (buyer is unknown, tag is free). +} + + +// Payment on customer order +if (GETPOST("source") == 'order' && $valid) +{ + $found=true; + $langs->load("orders"); + + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + + $order=new Commande($db); + $result=$order->fetch('',$ref); + if ($result < 0) + { + $mesg=$order->error; + $error++; + } + else + { + $result=$order->fetch_thirdparty($order->socid); + } + + $amount=$order->total_ttc; + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='ORD='.$order->ref.'.CUS='.$order->thirdparty->id; + //$fulltag.='.NAM='.strtr($order->thirdparty->name,"-"," "); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + // Creditor + + print ''."\n"; + + // Debitor + + print ''."\n"; + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // Shipping address + $shipToName=$order->thirdparty->name; + $shipToStreet=$order->thirdparty->address; + $shipToCity=$order->thirdparty->town; + $shipToState=$order->thirdparty->state_code; + $shipToCountryCode=$order->thirdparty->country_code; + $shipToZip=$order->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$order->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print 'ref.'">'."\n"; +} + + +// Payment on customer invoice +if (GETPOST("source") == 'invoice' && $valid) +{ + $found=true; + $langs->load("bills"); + + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + + $invoice=new Facture($db); + $result=$invoice->fetch('',$ref); + if ($result < 0) + { + $mesg=$invoice->error; + $error++; + } + else + { + $result=$invoice->fetch_thirdparty($invoice->socid); + } + + $amount=price2num($invoice->total_ttc - $invoice->getSommePaiement()); + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='INV='.$invoice->ref.'.CUS='.$invoice->thirdparty->id; + //$fulltag.='.NAM='.strtr($invoice->thirdparty->name,"-"," "); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + // Creditor + + print ''."\n"; + + // Debitor + + print ''."\n"; + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // Shipping address + $shipToName=$invoice->thirdparty->name; + $shipToStreet=$invoice->thirdparty->address; + $shipToCity=$invoice->thirdparty->town; + $shipToState=$invoice->thirdparty->state_code; + $shipToCountryCode=$invoice->thirdparty->country_code; + $shipToZip=$invoice->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$invoice->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print 'ref.'">'."\n"; +} + +// Payment on contract line +if (GETPOST("source") == 'contractline' && $valid) +{ + $found=true; + $langs->load("contracts"); + + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + + $contractline=new ContratLigne($db); + $result=$contractline->fetch('',$ref); + if ($result < 0) + { + $mesg=$contractline->error; + $error++; + } + else + { + if ($contractline->fk_contrat > 0) + { + $contract=new Contrat($db); + $result=$contract->fetch($contractline->fk_contrat); + if ($result > 0) + { + $result=$contract->fetch_thirdparty($contract->socid); + } + else + { + $mesg=$contract->error; + $error++; + } + } + else + { + $mesg='ErrorRecordNotFound'; + $error++; + } + } + + $amount=$contractline->total_ttc; + if ($contractline->fk_product) + { + $product=new Product($db); + $result=$product->fetch($contractline->fk_product); + + // We define price for product (TODO Put this in a method in product class) + if (! empty($conf->global->PRODUIT_MULTIPRICES)) + { + $pu_ht = $product->multiprices[$contract->thirdparty->price_level]; + $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level]; + $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level]; + } + else + { + $pu_ht = $product->price; + $pu_ttc = $product->price_ttc; + $price_base_type = $product->price_base_type; + } + + $amount=$pu_ttc; + if (empty($amount)) + { + dol_print_error('','ErrorNoPriceDefinedForThisProduct'); + exit; + } + } + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='COL='.$contractline->ref.'.CON='.$contract->ref.'.CUS='.$contract->thirdparty->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M'); + //$fulltag.='.NAM='.strtr($contract->thirdparty->name,"-"," "); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + $qty=1; + if (GETPOST('qty')) $qty=GETPOST('qty'); + + // Creditor + + print ''."\n"; + + // Debitor + + print ''."\n"; + + // Quantity + + $label=$langs->trans("Quantity"); + $qty=1; + $duration=''; + if ($contractline->fk_product) + { + if ($product->isService() && $product->duration_value > 0) + { + $label=$langs->trans("Duration"); + + // TODO Put this in a global method + if ($product->duration_value > 1) + { + $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("DurationDays"),"w"=>$langs->trans("DurationWeeks"),"m"=>$langs->trans("DurationMonths"),"y"=>$langs->trans("DurationYears")); + } + else + { + $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("DurationDay"),"w"=>$langs->trans("DurationWeek"),"m"=>$langs->trans("DurationMonth"),"y"=>$langs->trans("DurationYear")); + } + $duration=$product->duration_value.' '.$dur[$product->duration_unit]; + } + } + print ''; + print ''."\n"; + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // Shipping address + $shipToName=$contract->thirdparty->name; + $shipToStreet=$contract->thirdparty->address; + $shipToCity=$contract->thirdparty->town; + $shipToState=$contract->thirdparty->state_code; + $shipToCountryCode=$contract->thirdparty->country_code; + $shipToZip=$contract->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$contract->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print 'ref.'">'."\n"; +} + +// Payment on member subscription +if (GETPOST("source") == 'membersubscription' && $valid) +{ + $found=true; + $langs->load("members"); + + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; + + $member=new Adherent($db); + $result=$member->fetch('',$ref); + if ($result < 0) + { + $mesg=$member->error; + $error++; + } + else + { + $subscription=new Subscription($db); + } + + $amount=$subscription->total_ttc; + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + + $fulltag='MEM='.$member->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M'); + if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } + $fulltag=dol_string_unaccent($fulltag); + + // Creditor + + print ''."\n"; + + // Debitor + + print ''."\n"; + + if ($member->last_subscription_date || $member->last_subscription_amount) + { + // Last subscription date + + print ''."\n"; + + // Last subscription amount + + print ''."\n"; + + if (empty($amount) && ! GETPOST('newamount')) $_GET['newamount']=$member->last_subscription_amount; + } + + // Amount + + print ''."\n"; + + // Tag + + print ''."\n"; + + // Shipping address + $shipToName=$member->getFullName($langs); + $shipToStreet=$member->address; + $shipToCity=$member->town; + $shipToState=$member->state_code; + $shipToCountryCode=$member->country_code; + $shipToZip=$member->zip; + $shipToStreet2=''; + $phoneNum=$member->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + print ''."\n"; +} + + + + +if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters"); + +if ($mesg) print ''."\n"; + +print '
'.$langs->trans("ThisIsInformationOnPayment").' :
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("ThirdParty"); + print ''.$order->thirdparty->name.''; + + // Object + + $text=''.$langs->trans("PaymentOrderRef",$order->ref).''; + print '
'.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
'.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("ThirdParty"); + print ''.$invoice->thirdparty->name.''; + + // Object + + $text=''.$langs->trans("PaymentInvoiceRef",$invoice->ref).''; + print '
'.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
'.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("ThirdParty"); + print ''.$contract->thirdparty->name.''; + + // Object + + $text=''.$langs->trans("PaymentRenewContractId",$contract->ref,$contractline->ref).''; + if ($contractline->fk_product) + { + $text.='
'.$product->ref.($product->label?' - '.$product->label:''); + } + if ($contractline->description) $text.='
'.dol_htmlentitiesbr($contractline->description); + //if ($contractline->date_fin_validite) { + // $text.='
'.$langs->trans("DateEndPlanned").': '; + // $text.=dol_print_date($contractline->date_fin_validite); + //} + if ($contractline->date_fin_validite) + { + $text.='
'.$langs->trans("ExpiredSince").': '.dol_print_date($contractline->date_fin_validite); + } + + print '
'.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
'.$label.''.($duration?$duration:$qty).''; + print ''; + print '
'.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + print ''; + print ''; + } + else { + print ''.price($amount).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("Member"); + print ''; + if ($member->morphy == 'mor' && ! empty($member->societe)) print $member->societe; + else print $member->getFullName($langs); + print ''; + + // Object + + $text=''.$langs->trans("PaymentSubscription").''; + print '
'.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
'.$langs->trans("LastSubscriptionDate"); + print ''.dol_print_date($member->last_subscription_date,'day'); + print '
'.$langs->trans("LastSubscriptionAmount"); + print ''.price($member->last_subscription_amount); + print '
'.$langs->trans("Amount"); + if (empty($amount)) + { + print ' ('.$langs->trans("ToComplete"); + if (! empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) print ' - '.$langs->trans("SeeHere").''; + print ')'; + } + print ''; + if (empty($amount) || ! is_numeric($amount)) + { + $valtoshow=GETPOST("newamount",'int'); + if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); + print ''; + print ''; + } + else { + $valtoshow=$amount; + if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); + print ''.price($valtoshow).''; + print ''; + print ''; + } + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '

'.$mesg.'
'."\n"; +print "\n"; + +if ($found && ! $error) // We are in a management option and no error +{ + if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; + + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') + { + print '
'; + } + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') + { + print '
'; + } +} +else +{ + dol_print_error_email('ERRORNEWPAYMENTPAYPAL'); +} + +print '
'."\n"; +print '
'."\n"; +print '
'."\n"; +print '
'; + + +html_print_paypal_footer($mysoc,$langs); + +llxFooterPaypal(); + +$db->close(); diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php new file mode 100644 index 00000000000..70dac3c960b --- /dev/null +++ b/htdocs/public/payment/paymentko.php @@ -0,0 +1,146 @@ + + * Copyright (C) 2006-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/public/payment/paymentko.php + * \ingroup core + * \brief File to show page after a failed payment. + * This page is called by payment system with url provided to it competed with parameter TOKEN=xxx + * This token can be used to get more informations. + * \author Laurent Destailleur + */ + +define("NOLOGIN",1); // This means this output page does not require to be logged. +define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) define("DOLENTITY", $entity); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +if (! empty($conf->paypal->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; +} + +$langs->load("main"); +$langs->load("other"); +$langs->load("dict"); +$langs->load("bills"); +$langs->load("companies"); +$langs->load("paybox"); +$langs->load("paypal"); + +$PAYPALTOKEN=GETPOST('TOKEN'); +if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); +$PAYPALPAYERID=GETPOST('PAYERID'); +if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); +$PAYPALFULLTAG=GETPOST('FULLTAG'); +if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); + +$paymentmethod=array(); +if (! empty($conf->paypal->enabled)) $paymentmethod['paypal']='paypal'; +if (! empty($conf->paybox->enabled)) $paymentmethod['paybox']='paybox'; + + +// Security check +if (empty($paymentmethod)) accessforbidden('', 0, 0, 1); + + +/* + * Actions + */ + + + + +/* + * View + */ + +dol_syslog("Callback url when a PayPal payment was canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_payment'); + +$tracepost = ""; +foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; +dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment'); + + +// Send an email +if (! empty($conf->paypal->enabled)) +{ + if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) + { + // Get on url call + $token = $PAYPALTOKEN; + $fulltag = $PAYPALFULLTAG; + $payerID = $PAYPALPAYERID; + // Set by newpayment.php + $paymentType = $_SESSION['PaymentType']; + $currencyCodeType = $_SESSION['currencyCodeType']; + $FinalPaymentAmt = $_SESSION["Payment_Amount"]; + // From env + $ipaddress = $_SESSION['ipaddress']; + + + $sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + + $urlback=$_SERVER["REQUEST_URI"]; + $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentFailed"); + $content=$langs->transnoentitiesnoconv("NewPaypalPaymentFailed")."\ntag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($topic, $sendto, $from, $content); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + } + } +} + +$head=''; +if (! empty($conf->global->PAYMENT_CSS_URL)) $head=''."\n"; + +llxHeader($head, $langs->trans("PaymentForm")); + + +// Show ko message +print ''."\n"; +print '
'."\n"; +print $langs->trans("YourPaymentHasNotBeenRecorded")."

"; + +if (! empty($conf->global->PAYPAL_MESSAGE_KO)) print $conf->global->PAYPAL_MESSAGE_KO; +print "\n
\n"; + + +html_print_paypal_footer($mysoc,$langs); + + +llxFooter(); + +$db->close(); diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php new file mode 100644 index 00000000000..ce3fcd8bb29 --- /dev/null +++ b/htdocs/public/payment/paymentok.php @@ -0,0 +1,308 @@ + + * Copyright (C) 2006-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/public/payment/paymentok.php + * \ingroup core + * \brief File to show page after a successful payment + * This page is called by payment system with url provided to it completed with parameter TOKEN=xxx + * This token can be used to get more informations. + * \author Laurent Destailleur + */ + +define("NOLOGIN",1); // This means this output page does not require to be logged. +define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) define("DOLENTITY", $entity); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +if (! empty($conf->paypal->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; +} + +// Security check +//if (empty($conf->paypal->enabled)) accessforbidden('',0,0,1); + +$langs->load("main"); +$langs->load("other"); +$langs->load("dict"); +$langs->load("bills"); +$langs->load("companies"); +$langs->load("paybox"); +$langs->load("paypal"); + +// Clean parameters +if (! empty($conf->paypal->enabled)) +{ + $PAYPAL_API_USER=""; + if (! empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER; + $PAYPAL_API_PASSWORD=""; + if (! empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD; + $PAYPAL_API_SIGNATURE=""; + if (! empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE; + $PAYPAL_API_SANDBOX=""; + if (! empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX; + $PAYPAL_API_OK=""; + if ($urlok) $PAYPAL_API_OK=$urlok; + $PAYPAL_API_KO=""; + if ($urlko) $PAYPAL_API_KO=$urlko; + if (empty($PAYPAL_API_USER)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_USER not defined"); + return -1; + } + if (empty($PAYPAL_API_PASSWORD)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_PASSWORD not defined"); + return -1; + } + if (empty($PAYPAL_API_SIGNATURE)) + { + dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE not defined"); + return -1; + } +} + +$source=GETPOST('source'); +$ref=GETPOST('ref'); +$PAYPALTOKEN=GETPOST('TOKEN'); +if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); +$PAYPALPAYERID=GETPOST('PAYERID'); +if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); +$PAYPALFULLTAG=GETPOST('FULLTAG'); +if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); + +$paymentmethod=array(); +if (! empty($conf->paypal->enabled)) $paymentmethod['paypal']='paypal'; +if (! empty($conf->paybox->enabled)) $paymentmethod['paybox']='paybox'; + + +// Security check +if (empty($paymentmethod)) accessforbidden('', 0, 0, 1); + + +/* + * Actions + */ + + + +/* + * View + */ + +dol_syslog("Callback url when a payment was done. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_payment'); + +$tracepost = ""; +foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; +dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment'); + +$head=''; +if (! empty($conf->global->PAYMENT_CSS_URL)) $head=''."\n"; + +llxHeader($head, $langs->trans("PaymentForm")); + + +// Show message +print ''."\n"; +print '
'."\n"; + +if (! empty($conf->paypal->enabled)) +{ + if ($PAYPALTOKEN) + { + // Get on url call + $token = $PAYPALTOKEN; + $fulltag = $PAYPALFULLTAG; + $payerID = $PAYPALPAYERID; + // Set by newpayment.php + $paymentType = $_SESSION['PaymentType']; + $currencyCodeType = $_SESSION['currencyCodeType']; + $FinalPaymentAmt = $_SESSION["Payment_Amount"]; + // From env + $ipaddress = $_SESSION['ipaddress']; + + dol_syslog("Call paymentok with token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_paypal'); + + + // Validate record + if (! empty($paymentType)) + { + dol_syslog("We call GetExpressCheckoutDetails", LOG_DEBUG, 0, '_payment'); + $resArray=getDetails($token); + //var_dump($resarray); + + dol_syslog("We call DoExpressCheckoutPayment token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_payment'); + $resArray=confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag); + + $ack = strtoupper($resArray["ACK"]); + if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") + { + $object = new stdClass(); + + $object->source = $source; + $object->ref = $ref; + $object->payerID = $payerID; + $object->fulltag = $fulltag; + $object->resArray = $resArray; + + // resArray was built from a string like that + // TOKEN=EC%2d1NJ057703V9359028&TIMESTAMP=2010%2d11%2d01T11%3a40%3a13Z&CORRELATIONID=1efa8c6a36bd8&ACK=Success&VERSION=56&BUILD=1553277&TRANSACTIONID=9B994597K9921420R&TRANSACTIONTYPE=expresscheckout&PAYMENTTYPE=instant&ORDERTIME=2010%2d11%2d01T11%3a40%3a12Z&AMT=155%2e57&FEEAMT=5%2e54&TAXAMT=0%2e00&CURRENCYCODE=EUR&PAYMENTSTATUS=Completed&PENDINGREASON=None&REASONCODE=None + $PAYMENTSTATUS=urldecode($resArray["PAYMENTSTATUS"]); // Should contains 'Completed' + $TRANSACTIONID=urldecode($resArray["TRANSACTIONID"]); + $TAXAMT=urldecode($resArray["TAXAMT"]); + $NOTE=urldecode($resArray["NOTE"]); + + print $langs->trans("YourPaymentHasBeenRecorded")."
\n"; + print $langs->trans("ThisIsTransactionId",$TRANSACTIONID)."

\n"; + if (! empty($conf->global->PAYPAL_MESSAGE_OK)) print $conf->global->PAYPAL_MESSAGE_OK; + + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $result=$interface->run_triggers('PAYPAL_PAYMENT_OK',$object,$user,$langs,$conf); + if ($result < 0) { $error++; $errors=$interface->errors; } + // Fin appel triggers + + // Send an email + if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) + { + $sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $urlback=$_SERVER["REQUEST_URI"]; + $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentReceived"); + $tmptag=dolExplodeIntoArray($fulltag,'.','='); + $content=""; + if (! empty($tmptag['MEM'])) + { + $langs->load("members"); + $url=$urlwithroot."/adherents/card_subscriptions.php?rowid=".$tmptag['MEM']; + $content.=$langs->trans("PaymentSubscription")."
\n"; + $content.=$langs->trans("MemberId").': '.$tmptag['MEM']."
\n"; + $content.=$langs->trans("Link").': '.$url.''."
\n"; + } + else + { + $content.=$langs->transnoentitiesnoconv("NewPaypalPaymentReceived")."
\n"; + } + $content.="
\n"; + $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":
\n"; + $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
\n"; + $content.="tag=".$fulltag." token=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + + $ishtml=dol_textishtml($content); // May contain urls + + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + } + } + } + else + { + //Display a user friendly Error on the page using any of the following error information returned by PayPal + $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); + $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); + $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); + $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); + + echo $langs->trans('DoExpressCheckoutPaymentAPICallFailed') . "
\n"; + echo $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."
\n"; + echo $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."
\n"; + echo $langs->trans('ErrorCode') . ": " . $ErrorCode."
\n"; + echo $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."
\n"; + + if ($mysoc->email) echo "\nPlease, send a screenshot of this page to ".$mysoc->email."
\n"; + + // Send an email + if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) + { + $sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $urlback=$_SERVER["REQUEST_URI"]; + $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("ValidationOfPaypalPaymentFailed"); + $content=""; + $content.=$langs->transnoentitiesnoconv("PaypalConfirmPaymentPageWasCalledButFailed")."\n"; + $content.="\n"; + $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":\n"; + $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."\n"; + $content.="tag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + + $ishtml=dol_textishtml($content); // May contain urls + + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + } + } + } + } + else + { + dol_print_error('','Session expired'); + } + } +} +else +{ + // No TOKEN parameter in URL + dol_print_error('','No TOKEN parameter in URL'); +} + +print "\n
\n"; + +html_print_paypal_footer($mysoc,$langs); + + +llxFooter(); + +$db->close(); From 0080821dc5b4a3c40f7f5ddf5b8cd12f267c4983 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Apr 2017 16:05:54 +0200 Subject: [PATCH 11/34] Fix no invoice if not a customer --- htdocs/comm/card.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 4d4d50a1979..d5d11941b23 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1030,11 +1030,14 @@ if ($id > 0) if (! empty($conf->commande->enabled)) { - if (! empty($orders2invoice) && $orders2invoice > 0) print ''; - else print ''; + if ($object->client != 0 && $object->client != 2) + { + if (! empty($orders2invoice) && $orders2invoice > 0) print ''; + else print ''; + } + else print ''; } - - if ($object->client != 0) print ''; + if ($object->client != 0 && $object->client != 2) print ''; else print ''; } From ec59f08e419dc3c81df14ffcd5a71f231331b9ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Apr 2017 00:46:27 +0200 Subject: [PATCH 12/34] FIX extrafield css for boolean type --- htdocs/core/class/extrafields.class.php | 4 ++++ htdocs/core/tpl/admin_extrafields_view.tpl.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 673f069d1b3..def56c5203a 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -728,6 +728,10 @@ class ExtraFields { $showsize='minwidth400imp'; } + elseif ($type == 'boolean') + { + $showsize=''; + } else { if (round($size) < 12) diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index d20184c70b4..2143fc294c7 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -34,7 +34,7 @@ print '
'; $extrafields->fetch_name_optionals_label($elementtype); print '
'; -print ""; +print '
'; print ''; print ''; From af56c85057c9201f7a6a10abf9f400a36b4aca6a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Apr 2017 03:11:19 +0200 Subject: [PATCH 13/34] Fix perms on file --- .../swiftmailer/lib/swiftmailer_generate_mimes_config.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php diff --git a/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php b/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php old mode 100644 new mode 100755 From 65fec95458f17fdd87673fb737fabd2f04b4e5f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Apr 2017 03:15:03 +0200 Subject: [PATCH 14/34] Fix debian package --- build/debian/dolibarr.postinst | 2 +- build/debian/install.forced.php.install | 2 +- build/makepack-dolibarr.pl | 3 ++- htdocs/core/modules/import/import_xlsx.modules.php | 2 +- htdocs/install/fileconf.php | 8 ++++---- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/build/debian/dolibarr.postinst b/build/debian/dolibarr.postinst index 4b946fda433..6ee2a89931f 100644 --- a/build/debian/dolibarr.postinst +++ b/build/debian/dolibarr.postinst @@ -61,7 +61,7 @@ apache_install() { # Enable dolibarr conf if which a2enconf >/dev/null 2>&1 ;then # a2enconf exists for ubuntu only - echo "Enable link for Apache config file with a3enconf" + echo "Enable link for Apache config file with a2enconf" a2enconf dolibarr else if [ -d /etc/$webserver/conf.d ] && [ ! -e /etc/$webserver/conf.d/dolibarr.conf ]; then diff --git a/build/debian/install.forced.php.install b/build/debian/install.forced.php.install index 56eef3287a6..e55ffae138e 100644 --- a/build/debian/install.forced.php.install +++ b/build/debian/install.forced.php.install @@ -7,7 +7,7 @@ // $force_install_packager='deb'; -$force_install_noedit=2; +$force_install_noedit=1; $force_install_message='KeepDefaultValuesDeb'; #$force_install_main_data_root='/usr/share/dolibarr/documents'; $force_install_main_data_root='/var/lib/dolibarr/documents'; diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index c06d8f0730f..f465cf51234 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -509,7 +509,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/documents`; # Removed known external modules to avoid any error when packaging from env where external modules are tested - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/custom/*`; # For custom we want to keep dir + #$ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \;`; # For custom we want to keep dir $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/allscreens*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/ancotec*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/cabinetmed*`; @@ -554,6 +554,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/doc`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/example`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/test`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mobiledetect/mobiledetectlib/.gitmodules`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/samples`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/php-iban/docs`; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 627fcfd6fd9..917760dc900 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/import/modules_import.php'; /** * Class to import Excel files */ -class Importxlsx extends ModeleImports +class ImportXlsx extends ModeleImports { var $db; var $datatoimport; diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 2b8f57d9d3c..cdd639ad50b 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -45,13 +45,13 @@ dolibarr_install_syslog("--- fileconf: entering fileconf.php page"); // install.forced.php into directory htdocs/install (This is the case with some wizard // installer like DoliWamp, DoliMamp or DoliBuntu). // We first init "forced values" to nothing. -if (! isset($force_install_noedit)) $force_install_noedit=''; // 1=To block var specific to distrib, 2 to block all technical parameters +if (! isset($force_install_noedit)) $force_install_noedit=''; // 1=To block vars specific to distrib, 2 to block all technical parameters if (! isset($force_install_type)) $force_install_type=''; if (! isset($force_install_dbserver)) $force_install_dbserver=''; if (! isset($force_install_port)) $force_install_port=''; if (! isset($force_install_database)) $force_install_database=''; -if (! isset($force_install_prefix)) $force_install_prefix=''; -if (! isset($force_install_createdatabase)) $force_install_createdatabase=''; +if (! isset($force_install_prefix)) $force_install_prefix=''; +if (! isset($force_install_createdatabase)) $force_install_createdatabase=''; if (! isset($force_install_databaselogin)) $force_install_databaselogin=''; if (! isset($force_install_databasepass)) $force_install_databasepass=''; if (! isset($force_install_databaserootlogin)) $force_install_databaserootlogin=''; @@ -324,7 +324,7 @@ if (! empty($force_install_message)) ?> '; - $choice .= ''; $choice .= ''; - $choice .= ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print '
'.$langs->trans("Position").'
'.$langs->trans("FreshInstall").''; $choice .= ''; + $choice .= ''; $choice .= $langs->trans("FreshInstallDesc"); if (empty($dolibarr_main_db_host)) // This means install process was not run { @@ -459,7 +459,7 @@ else $choice .= '
'.$langs->trans("Upgrade").'
'.$newversionfrom.$newversionfrombis.' -> '.$newversionto.'
'; + $choice .= ''; $choice .= $langs->trans("UpgradeDesc"); if ($recommended_choice) diff --git a/htdocs/install/default.css b/htdocs/install/default.css index 257f2d99af8..9725b06b8bc 100644 --- a/htdocs/install/default.css +++ b/htdocs/install/default.css @@ -1,5 +1,5 @@ /* Copyright (C) 2004 Rodolphe Quiedeville - * Copyright (C) 2009-2016 Laurent Destailleur + * Copyright (C) 2009-2017 Laurent Destailleur * * 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 @@ -210,7 +210,9 @@ table.listofchoices, tr.listofchoices, td.listofchoices { tr.listofchoices { height: 42px; } - +.listofchoicesdesc { + color: #999 !important; +} .blinkwait { font-weight: bold; text-decoration:blink !important; @@ -244,9 +246,8 @@ font.warning { div.error { color: #550000; font-weight: bold; - padding: 0.2em 0.2em 0.2em 0.2em; + padding: 0.2em 0.2em 0.2em 0; margin: 0.5em 0 0.5em 0; - border: 1px solid #6C7C8B; } font.error { color: #550000; diff --git a/htdocs/langs/en_US/bookmarks.lang b/htdocs/langs/en_US/bookmarks.lang index d15ed3e1148..9d2003f34d3 100644 --- a/htdocs/langs/en_US/bookmarks.lang +++ b/htdocs/langs/en_US/bookmarks.lang @@ -12,7 +12,7 @@ BookmarkTargetNewWindowShort=New window BookmarkTargetReplaceWindowShort=Current window BookmarkTitle=Bookmark title UrlOrLink=URL -BehaviourOnClick=Behaviour when a URL is clicked +BehaviourOnClick=Behaviour when a bookmark URL is selected CreateBookmark=Create bookmark SetHereATitleForLink=Set a title for the bookmark UseAnExternalHttpLinkOrRelativeDolibarrLink=Use an external http URL or a relative Dolibarr URL From aa4b967e172c1a5d4d306d968648ba1b5cb73dab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Apr 2017 11:46:12 +0200 Subject: [PATCH 18/34] FIX image of rss when link is relative Fix regression after disabling constant init. --- htdocs/admin/external_rss.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 7f81a5d0fef..30646b749fa 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -206,13 +206,13 @@ print ''.$langs->trans("Example").'
'.$langs->trans("Title").''.$langs->trans('RSSUrlExample').'
'.$langs->trans('RSSUrl').'http://news.google.com/news?ned=us&topic=h&output=rss
http://www.dolibarr.org/rss
'; @@ -243,10 +243,12 @@ if ($resql) preg_match('/^([0-9]+)/i',$obj->note,$reg); $idrss = $reg[1]; - //print "x".$idrss; + $keyrssurl="EXTERNAL_RSS_URLRSS_".$idrss; + $keyrsstitle="EXTERNAL_RSS_URLRSS_".$idrss; + //print "x".$idrss; $rssparser=new RssParser($db); - $result = $rssparser->parser(@constant("EXTERNAL_RSS_URLRSS_".$idrss), 5, 300, $conf->externalrss->dir_temp); + $result = $rssparser->parser($conf->global->$keyrssurl, 5, 300, $conf->externalrss->dir_temp); $var=true; @@ -269,13 +271,13 @@ if ($resql) print ''; print "".$langs->trans("Title").""; - print ""; + print "global->$keyrsstitle . "\">"; print ""; print ''; print "".$langs->trans("URL").""; - print ""; + print "global->$keyrssurl . "\">"; print ""; @@ -304,6 +306,8 @@ if ($resql) print "".$langs->trans("Logo").""; print ''; $imageurl=$rssparser->getImageUrl(); + $linkrss=$rssparser->getLink(); + if (! preg_match('/^http/', $imageurl)) $imageurl=$linkrss.$imageurl; if ($imageurl) print ''; else print $langs->trans("None"); print ''; From 1c20bbb2871808e3e6ee4d5ecf7874a3721c5f4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Apr 2017 12:07:32 +0200 Subject: [PATCH 19/34] NEW Add index and constraints keys on supplier proposal detail table --- .../install/mysql/migration/5.0.0-6.0.0.sql | 5 ++++ .../tables/llx_supplier_proposaldet.key.sql | 26 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_supplier_proposaldet.key.sql diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index e73c0df2add..9ff9de4e70d 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -173,4 +173,9 @@ create table llx_default_values ALTER TABLE llx_default_values ADD UNIQUE INDEX uk_default_values(type, entity, user_id, page, param); +ALTER TABLE llx_supplier_proposaldet ADD INDEX idx_supplier_proposaldet_fk_supplier_proposal (fk_supplier_proposal); +ALTER TABLE llx_supplier_proposaldet ADD INDEX idx_supplier_proposaldet_fk_product (fk_product); + +ALTER TABLE llx_supplier_proposaldet ADD CONSTRAINT fk_supplier_proposaldet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid); +ALTER TABLE llx_supplier_proposaldet ADD CONSTRAINT fk_supplier_proposaldet_fk_supplier_proposal FOREIGN KEY (fk_supplier_proposal) REFERENCES llx_supplier_proposal (rowid); diff --git a/htdocs/install/mysql/tables/llx_supplier_proposaldet.key.sql b/htdocs/install/mysql/tables/llx_supplier_proposaldet.key.sql new file mode 100644 index 00000000000..e6af3c7e515 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_supplier_proposaldet.key.sql @@ -0,0 +1,26 @@ +-- =================================================================== +-- Copyright (C) 2009-2011 Regis Houssin +-- Copyright (C) 2012 Cédric Salvador +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + + + +ALTER TABLE llx_supplier_proposaldet ADD INDEX idx_supplier_proposaldet_fk_supplier_proposal (fk_supplier_proposal); +ALTER TABLE llx_supplier_proposaldet ADD INDEX idx_supplier_proposaldet_fk_product (fk_product); + +ALTER TABLE llx_supplier_proposaldet ADD CONSTRAINT fk_supplier_proposaldet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid); +ALTER TABLE llx_supplier_proposaldet ADD CONSTRAINT fk_supplier_proposaldet_fk_supplier_proposal FOREIGN KEY (fk_supplier_proposal) REFERENCES llx_supplier_proposal (rowid); From 508109d5b1201c925fde31cbf35fab0df65f6c36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 00:21:00 +0200 Subject: [PATCH 20/34] Translation --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4653a22d814..42c6eedae08 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1527,7 +1527,7 @@ EndPointIs=SOAP clients must send their requests to the Dolibarr endpoint availa ApiSetup=API module setup ApiDesc=By enabling this module, Dolibarr become a REST server to provide miscellaneous web services. ApiProductionMode=Enable production mode (this will activate use of a cache for services management) -ApiExporerIs=You can explore the APIs at url +ApiExporerIs=You can explore and test the APIs at URL OnlyActiveElementsAreExposed=Only elements from enabled modules are exposed ApiKey=Key for API WarningAPIExplorerDisabled=The API explorer has been disabled. API explorer is not required to provide API services. It is a tool for developer to find/test REST APIs. If you need this tool, go into setup of module API REST to activate it. From 95788c96994980b12bf13464795bb9b6fc1e294f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 00:53:13 +0200 Subject: [PATCH 21/34] FIX A non admin user can not download files attached to user. --- htdocs/core/lib/files.lib.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index d27d6c1cdb1..87a587a7460 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1385,7 +1385,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu $sqlprotectagainstexternals=''; $ret=array(); - // find the subdirectory name as the reference + // Find the subdirectory name as the reference. For exemple original_file='10/myfile.pdf' -> refname='10' if (empty($refname)) $refname=basename(dirname($original_file)."/"); $relative_original_file = $original_file; @@ -1553,6 +1553,18 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu $original_file=$conf->fckeditor->dir_output.'/'.$original_file; } + // Wrapping for users + else if ($modulepart == 'user' && !empty($conf->user->dir_output)) + { + $canreaduser=(! empty($fuser->admin) || $fuser->rights->user->user->lire); + if ($user->id == (int) $refname) { $canreaduser=1; } // A user can always read its own card + if ($canreaduser || preg_match('/^specimen/i',$original_file)) + { + $accessallowed=1; + } + $original_file=$conf->user->dir_output.'/'.$original_file; + } + // Wrapping for third parties else if (($modulepart == 'company' || $modulepart == 'societe') && !empty($conf->societe->dir_output)) { From d390acc8886a7f48899e5bf180b1d4f42d9c45c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 02:03:59 +0200 Subject: [PATCH 22/34] FIX A non admin user can not download files attached to user. --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 87a587a7460..2faa3ae1a8f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1557,7 +1557,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu else if ($modulepart == 'user' && !empty($conf->user->dir_output)) { $canreaduser=(! empty($fuser->admin) || $fuser->rights->user->user->lire); - if ($user->id == (int) $refname) { $canreaduser=1; } // A user can always read its own card + if ($fuser->id == (int) $refname) { $canreaduser=1; } // A user can always read its own card if ($canreaduser || preg_match('/^specimen/i',$original_file)) { $accessallowed=1; From e97fae0c43f0cbfd0cc53dfdadd5e49ef0913835 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 12:10:08 +0200 Subject: [PATCH 23/34] Fix typo --- htdocs/install/mysql/migration/repair.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 03c1ab07dfd..32696ecf593 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -15,8 +15,8 @@ -- Requests to change character set and collation of a column --- ALTER TABLE llx_accountingaccount MODIFY account_number VARCHAR(20) CHARACTER SET utf8; --- ALTER TABLE llx_accountingaccount MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; +-- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; +-- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; -- You can check with "show full columns from llx_accountingaccount"; From 1a98c4a3ffcc8e7201c45ed3021f40c6ec71eb9a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 12:48:13 +0200 Subject: [PATCH 24/34] Fix error management in adding translation key --- htdocs/admin/translation.php | 20 ++++++++++++++++---- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/errors.lang | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 7d07f7ead94..789e85d167d 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -75,7 +75,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $transkey=''; $transvalue=''; @@ -116,7 +116,11 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update')) } else { - dol_print_error($db); + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings'); + } + else dol_print_error($db); $action=''; } } @@ -422,9 +426,17 @@ if ($mode == 'searchkey') print ''.$langcode.''.$key.''; print dol_escape_htmltag($val); print ''; - if ($val != $newlangfileonly->tab_translate[$key]) + if (! empty($newlangfileonly->tab_translate[$key])) { - $htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]); + if ($val != $newlangfileonly->tab_translate[$key]) + { + $htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]); + print $form->textwithpicto('', $htmltext, 1, 'info'); + } + } + else + { + $htmltext = $langs->trans("TransKeyWithoutOriginalValue", $key); print $form->textwithpicto('', $htmltext, 1, 'warning'); } /*if (! empty($conf->multicompany->enabled) && !$user->entity) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index be60fc5db7c..504470b203d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1075,6 +1075,7 @@ CurrentTranslationString=Current translation string WarningAtLeastKeyOrTranslationRequired=A search criteria is required at least for key or translation string NewTranslationStringToShow=New translation string to show OriginalValueWas=The original translation is overwritten. Original value was:

%s +TransKeyWithoutOriginalValue=You forced a new translation for the translation key '%s' that does not exists in any language files TotalNumberOfActivatedModules=Total number of activated feature modules: %s / %s YouMustEnableOneModule=You must at least enable 1 module ClassNotFoundIntoPathWarning=Class %s not found into PHP path diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index af18693f9d4..72912ca2b1f 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -205,3 +205,4 @@ WarningPaymentDateLowerThanInvoiceDate=Payment date (%s) is earlier than invoice WarningTooManyDataPleaseUseMoreFilters=Too many data (more than %s lines). Please use more filters or set the constant %s to a higher limit. WarningSomeLinesWithNullHourlyRate=Some times were recorded by some users while their hourly rate was not defined. A value of 0 %s per hour was used but this may result in wrong valuation of time spent. WarningYourLoginWasModifiedPleaseLogin=Your login was modified. For security purpose you will have to login with your new login before next action. +WarningAnEntryAlreadyExistForTransKey=An entry already exists for the translation key for this language \ No newline at end of file From 9c2ce0202da0799a8994fef2921e0e887cd8cb82 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 13:19:07 +0200 Subject: [PATCH 25/34] Translation --- htdocs/langs/en_US/admin.lang | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 504470b203d..bae07caa381 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -298,12 +298,12 @@ LastActivationDate=Latest activation date UpdateServerOffline=Update server offline WithCounter=Manage a counter GenericMaskCodes=You may enter any numbering mask. In this mask, the following tags could be used:
{000000} corresponds to a number which will be incremented on each %s. Enter as many zeros as the desired length of the counter. The counter will be completed by zeros from the left in order to have as many zeros as the mask.
{000000+000} same as previous but an offset corresponding to the number to the right of the + sign is applied starting on first %s.
{000000@x} same as previous but the counter is reset to zero when month x is reached (x between 1 and 12, or 0 to use the early months of fiscal year defined in your configuration, or 99 to reset to zero every month). If this option is used and x is 2 or higher, then sequence {yy}{mm} or {yyyy}{mm} is also required.
{dd} day (01 to 31).
{mm} month (01 to 12).
{yy}, {yyyy} or {y} year over 2, 4 or 1 numbers.
-GenericMaskCodes2={cccc} the client code on n characters
{cccc000} the client code on n characters is followed by a counter dedicated for customer. This counter dedicated to customer is reset at same time than global counter.
{tttt} The code of third party type on n characters (see dictionary-thirdparty types).
+GenericMaskCodes2={cccc} the client code on n characters
{cccc000} the client code on n characters is followed by a counter dedicated for customer. This counter dedicated to customer is reset at same time than global counter.
{tttt} The code of third party type on n characters (see menu Home - Setup - Dictionary - Types of third parties). If you add this tag, the counter will be different for each type of third party.
GenericMaskCodes3=All other characters in the mask will remain intact.
Spaces are not allowed.
-GenericMaskCodes4a=Example on the 99th %s of the third party TheCompany done 2007-01-31:
+GenericMaskCodes4a=Example on the 99th %s of the third party TheCompany, with date 2007-01-31:
GenericMaskCodes4b=Example on third party created on 2007-03-01:
GenericMaskCodes4c=Example on product created on 2007-03-01:
-GenericMaskCodes5=ABC{yy}{mm}-{000000} will give ABC0701-000099
{0000+100@1}-ZZZ/{dd}/XXX will give 0199-ZZZ/31/XXX +GenericMaskCodes5=ABC{yy}{mm}-{000000} will give ABC0701-000099
{0000+100@1}-ZZZ/{dd}/XXX will give 0199-ZZZ/31/XXX
IN{yy}{mm}-{0000}-{t} will give IN0701-0099-A if the type of company is 'Responsable Inscripto' with code for type that is 'A_RI' GenericNumRefModelDesc=Returns a customizable number according to a defined mask. ServerAvailableOnIPOrPort=Server is available at address %s on port %s ServerNotAvailableOnIPOrPort=Server is not available at address %s on port %s From 1758b836042a3e1776af77a655bb2bc866e99b69 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 13:50:13 +0200 Subject: [PATCH 26/34] Clean explanation for accounting module setup. --- htdocs/accountancy/index.php | 9 ++++++--- htdocs/langs/en_US/accountancy.lang | 18 +++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 54772ebf1a4..ff9ca6fa1a3 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -129,15 +129,18 @@ if (! empty($conf->don->enabled)) print "
\n"; print "
\n"; }*/ + $step++; -$textlink=''.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuBankCash").''; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink); +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").''); print "
\n"; print "
\n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").'')."
\n"; +$textlink=''.$langs->transnoentitiesnoconv("MenuBankCash").''; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink); print "
\n"; +print "
\n"; + print "
\n"; print_fiche_titre($langs->trans("AccountancyAreaDescActionFreq"), '', 'object_calendarweek'); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 42c5c519d2c..57f220f943c 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -36,15 +36,15 @@ AccountancyAreaDescActionOnceBis=Next steps should be done to save you time in f AccountancyAreaDescActionFreq=The following actions are usually executed every month, week or day for very large companies... AccountancyAreaDescChartModel=STEP %s: Create a model of chart of account from menu %s AccountancyAreaDescChart=STEP %s: Create or check content of your chart of account from menu %s -AccountancyAreaDescBank=STEP %s: Check the binding between bank accounts and accounting account is done. Complete missing bindings. For this, go on the card of each financial account. You can start from page %s. -AccountancyAreaDescVat=STEP %s: Check the binding between vat rates and accounting account is done. Complete missing bindings. You can set accounting accounts to use for each VAT from page %s. -AccountancyAreaDescExpenseReport=STEP %s: Check the binding between type of expense report and accounting account is done. Complete missing bindings. You can set accounting accounts to use for each VAT from page %s. -AccountancyAreaDescSal=STEP %s: Check the binding between salaries payment and accounting account is done. Complete missing bindings. For this you can use the menu entry %s. -AccountancyAreaDescContrib=STEP %s: Check the binding between special expences (miscellaneous taxes) and accounting account is done. Complete missing bindings. For this you can use the menu entry %s. -AccountancyAreaDescDonation=STEP %s: Check the binding between donation and accounting account is done. Complete missing bindings. You can set the account dedicated for that from the menu entry %s. -AccountancyAreaDescMisc=STEP %s: Check the default binding between miscellaneous transaction lines and accounting account is done. Complete missing bindings. For this you can use the menu entry %s. -AccountancyAreaDescProd=STEP %s: Check the binding between products/services and accounting account is done. Complete missing bindings. For this you can use the menu entry %s. -AccountancyAreaDescLoan=STEP %s: Check the binding between loans payment and accounting account is done. Complete missing bindings. For this you can use the menu entry %s. +AccountancyAreaDescVat=STEP %s: Define accounting accounts for each VAT Rates. For this you can use the menu entry %s. +AccountancyAreaDescExpenseReport=STEP %s: Define default accounting accounts for type of expense report. For this you can use the menu entry %s. +AccountancyAreaDescSal=STEP %s: Define default accounting accounts for payment of salaries. For this you can use the menu entry %s. +AccountancyAreaDescContrib=STEP %s: Define default accounting accounts for special expences (miscellaneous taxes). For this you can use the menu entry %s. +AccountancyAreaDescDonation=STEP %s: Define default accounting accounts for donation. For this you can use the menu entry %s. +AccountancyAreaDescMisc=STEP %s: Define default accounting accounts for miscellaneous transactions. For this you can use the menu entry %s. +AccountancyAreaDescLoan=STEP %s: Define default accounting accounts for loans. For this you can use the menu entry %s. +AccountancyAreaDescBank=STEP %s: Define accounting accounts for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s. +AccountancyAreaDescProd=STEP %s: Define accounting accounts on your products. For this you can use the menu entry %s. AccountancyAreaDescCustomer=STEP %s: Check the binding between existing customer invoice lines and accounting account is done, so application will be able to journalize transactions in General Ledger in one click. Complete missing bindings. For this you can use the menu entry %s. AccountancyAreaDescSupplier=STEP %s: Check the binding between existing supplier invoice lines and accounting account is done, so application will be able to journalize transactions in General Ledger in one click. Complete missing bindings. For this you can use the menu entry %s. From 2f23b36ca1b4d31d92822332201c084844dad3d6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 14:20:06 +0200 Subject: [PATCH 27/34] Fix typo in var name picto --- htdocs/accountancy/admin/accountmodel.php | 4 ++-- htdocs/accountancy/customer/list.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index d2b039a28e0..0b4aa70e548 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -901,8 +901,8 @@ if ($id) if ($id == 4) print ''; print ''; print ''; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; + $searchpicto=$form->showFilterAndCheckAddButtons(0); + print $searchpicto; print ''; print ''; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 845e0a62540..c5830b0b003 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -285,7 +285,7 @@ if ($result) { print ''; print ''; print ''; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $searchpicto=$form->showFilterButtons(); print $searchpicto; print ''; print ''; @@ -303,7 +303,7 @@ if ($result) { print_liste_field_titre($langs->trans("IntoAccount"), '', '', '', '', 'align="center"'); $checkpicto=''; if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); - print_liste_field_titre($checkpitco, '', '', '', '', 'align="center"'); + print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"'); print "\n"; $facture_static = new Facture($db); From 5e856e692369eaf33c5ffa327b63a70792357397 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 17:16:19 +0200 Subject: [PATCH 28/34] More complete tooltip help to describe available substitution vars --- htdocs/admin/chequereceipts.php | 8 +++++++- htdocs/admin/commande.php | 13 +++++++------ htdocs/admin/contract.php | 11 +++++++++-- htdocs/admin/expedition.php | 10 ++++++++-- htdocs/admin/expensereport.php | 10 ++++++++-- htdocs/admin/facture.php | 13 +++++++------ htdocs/admin/fichinter.php | 11 +++++++++-- htdocs/admin/livraison.php | 8 +++++++- htdocs/admin/payment.php | 2 +- htdocs/admin/propal.php | 15 ++++++++------- htdocs/admin/supplier_invoice.php | 8 +++++++- htdocs/admin/supplier_order.php | 9 ++++++++- htdocs/admin/supplier_proposal.php | 11 +++++++++-- .../facture/admin/facture_cust_extrafields.php | 2 +- .../facture/admin/facturedet_cust_extrafields.php | 2 +- htdocs/fourn/card.php | 1 - htdocs/langs/en_US/companies.lang | 8 ++++---- htdocs/societe/agenda.php | 8 +------- htdocs/theme/eldy/style.css.php | 4 ++++ htdocs/theme/md/style.css.php | 3 +++ 20 files changed, 109 insertions(+), 48 deletions(-) diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 3b205f49cd2..fd1da0c328b 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -257,8 +257,14 @@ $var=true; $var=! $var; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + print ''; -print $langs->trans("FreeLegalTextOnChequeReceipts").' ('.$langs->trans("AddCRIfTooLong").')
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnChequeReceipts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='BANK_CHEQUERECEIPT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 3933f5d00ab..a4680f4d16e 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -565,12 +565,18 @@ print " \n"; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print '
'; print ''; print ''; print ''; -print $langs->trans("FreeLegalTextOnOrders").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -593,11 +599,6 @@ print ""; print ''; print ""; print ''; -$substitutionarray=pdf_getSubstitutionArray($langs); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); -$htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; print $form->textwithpicto($langs->trans("WatermarkOnDraftOrders"), $htmltext); print ''; print ''; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index bc3ea402704..ddd8c6f1c00 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -502,9 +502,15 @@ print ''.$langs->trans("Value").''; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print ''; -print $langs->trans("FreeLegalTextOnContracts").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='CONTRACT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -521,7 +527,8 @@ print ''."\n"; //Use draft Watermark print ''; -print $langs->trans("WatermarkOnDraftContractCards").''; +print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $htmltext); +print ''; print ''; print ''."\n"; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index ef8b10c411f..d31b788a1ab 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -502,8 +502,14 @@ print ""; print "".$langs->trans("Parameter")."\n"; print ""; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + print ''; -print $langs->trans("FreeLegalTextOnShippings").' ('.$langs->trans("AddCRIfTooLong").')
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='SHIPPING_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -518,7 +524,7 @@ else print "\n"; print ''; -print $langs->trans("WatermarkOnDraft").'
'; +print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $htmltext).'
'; print ''; print "\n"; diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index eda3c6bd6ae..dad17585e2e 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -505,9 +505,15 @@ print ''; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print ''; -print $langs->trans("FreeLegalTextOnExpenseReports").' ('.$langs->trans("AddCRIfTooLong").')
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnExpenseReports"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='EXPENSEREPORT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -524,7 +530,7 @@ print ''."\n"; //Use draft Watermark print ''; -print $langs->trans("WatermarkOnDraftOrders").'
'; +print $form->textwithpicto($langs->trans("WatermarkOnDraftExpenseReports"), $htmltext).'
'; print ''; print ''."\n"; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index e7f74f85e5e..d89c9711e3f 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -733,12 +733,18 @@ print '\n"; print '
'; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print '
'; print ''; print ''; print ''; -print $langs->trans("FreeLegalTextOnInvoices").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -760,11 +766,6 @@ print ''; print ''; print ''; print ''; -$substitutionarray=pdf_getSubstitutionArray($langs); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); -$htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; print $form->textwithpicto($langs->trans("WatermarkOnDraftBill"), $htmltext); print ''; print ''; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 6c73afcf8f5..0b01f56857e 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -534,12 +534,18 @@ print " \n"; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print ''; print ''; print ''; print ''; -print $langs->trans("FreeLegalTextOnInterventions").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnInterventions"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='FICHINTER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -562,7 +568,8 @@ print ""; print ''; print ""; print ''; -print $langs->trans("WatermarkOnDraftInterventionCards").''; +print $form->textwithpicto($langs->trans("WatermarkOnDraftInterventionCards"), $htmltext).'
'; +print ''; print ''; print ''; print ''; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 281f1934296..143c54ec24d 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -479,12 +479,18 @@ print ' '; print "\n"; $var=true; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print ''; print ''; print ''; print ''; -print $langs->trans("FreeLegalTextOnDeliveryReceipts").' ('.$langs->trans("AddCRIfTooLong").')
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='DELIVERY_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index a5166ec69f2..88f2d8cd1c1 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -117,7 +117,7 @@ $linkback=''.$langs->trans("BackToM print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); $head = invoice_admin_prepare_head(); -dol_fiche_head($head, 'payment', $langs->trans("Invoices"), 0, 'invoice'); +dol_fiche_head($head, 'payment', $langs->trans("Invoices"), -1, 'invoice'); /* * Numbering module diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 76179fac66c..6a9884e263c 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -570,11 +570,17 @@ print "\n"; print ''; */ +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + print '
'; print ''; print ''; print ''; -print $langs->trans("FreeLegalTextOnProposal").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnProposal"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -596,12 +602,7 @@ print ""; print ''; print ""; print ''; -$substitutionarray=pdf_getSubstitutionArray($langs); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); -$htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; -print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext); +print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext).'
'; print ''; print ''; print ''; diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 2619951e1b5..19f0e6fc8e2 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -471,8 +471,14 @@ print ''.$langs->trans("Value").''; print ' '; print "\n"; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + print ''; -print $langs->trans("FreeLegalTextOnInvoices").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='SUPPLIER_INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index d54f0e367aa..a30e7de2654 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -491,6 +491,7 @@ print ''.$langs->trans("Value").''; print ' '; print "\n"; $var=false; + //if ($conf->global->MAIN_FEATURES_LEVEL > 0) //{ print ''; @@ -536,8 +537,14 @@ else } */ +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + print ''; -print $langs->trans("FreeLegalTextOnOrders").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='SUPPLIER_ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 703fbc482e9..345f622a533 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -523,12 +523,18 @@ print ''.$langs->trans("Value")."\n"; print " \n"; print ""; +$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + $var=! $var; print ''; print ''; print ''; print ''; -print $langs->trans("FreeLegalTextOnSupplierProposal").' '.img_info($langs->trans("AddCRIfTooLong")).'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnSupplierProposal"), $langs->trans("AddCRIfTooLong").'

'.$htmltext).'
'; $variablename='SUPPLIER_PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { @@ -550,7 +556,8 @@ print ""; print ''; print ""; print ''; -print $langs->trans("WatermarkOnDraftSupplierProposal").''; +print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext).'
'; +print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index ae545c695c3..c7a43c737de 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -70,7 +70,7 @@ print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); $head = invoice_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Invoices"), 0, 'invoice'); +dol_fiche_head($head, 'attributes', $langs->trans("Invoices"), -1, 'invoice'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index d7fd3367b67..3a5f8c3387f 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -71,7 +71,7 @@ print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); $head = invoice_admin_prepare_head(); -dol_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), 0, 'invoice'); +dol_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), -1, 'invoice'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index a9ba1ef80aa..4c2716e311a 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -753,7 +753,6 @@ if ($object->id > 0) print '
'; - print '
'; if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) { diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 38d7a81ab9a..12d1ea188e6 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -77,10 +77,10 @@ VATIsNotUsed=VAT is not used CopyAddressFromSoc=Fill address with third party address ThirdpartyNotCustomerNotSupplierSoNoRef=Thirdparty neither customer nor supplier, no available refering objects PaymentBankAccount=Payment bank account -OverAllProposals=Total proposals -OverAllOrders=Total orders -OverAllInvoices=Total invoices -OverAllSupplierProposals=Total price requests +OverAllProposals=Proposals +OverAllOrders=Orders +OverAllInvoices=Invoices +OverAllSupplierProposals=Price requests ##### Local Taxes ##### LocalTax1IsUsed=Use second tax LocalTax1IsUsedES= RE is used diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index e1dc1c12671..32d13356654 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -83,7 +83,7 @@ if (empty($reshook)) } // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $actioncode=''; $search_agenda_label=''; @@ -180,12 +180,6 @@ if ($socid > 0) print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); - // List of todo actions - //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); - - // List of done actions - //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode); - // List of all actions $filters=array(); $filters['search_agenda_label']=$search_agenda_label; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 5c7f1f446ae..f0e615f29ce 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1973,6 +1973,10 @@ div.tabBar { width: auto; background: rgb(); } +div.tabBar div.titre { + padding-top: 10px; +} + div.tabBarWithBottom { padding-bottom: 18px; border-bottom: 1px solid #aaa; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 8cc95628561..d38391504fa 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1992,6 +1992,9 @@ div.tabBar { padding-bottom: 12px; border-bottom: 1px solid #aaa; } +div.tabBar div.titre { + padding-top: 10px; +} div.tabBarWithBottom { padding-bottom: 18px; border-bottom: 1px solid #aaa; From b87eb07b08963056e9da19b20e9599b95b784a42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 17:51:11 +0200 Subject: [PATCH 29/34] Look and feel v6 --- htdocs/accountancy/admin/export.php | 2 +- htdocs/accountancy/admin/index.php | 4 ++-- htdocs/accountancy/admin/journals.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index f7bbbb97969..eaf69f34f1f 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -130,7 +130,7 @@ print ''; print ''; print ''; -dol_fiche_head($head, 'export', $langs->trans("Configuration"), 0, 'cron'); +dol_fiche_head($head, 'export', $langs->trans("Configuration"), -1, 'cron'); $var = true; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 3ea77a24b43..899aaa1a3d2 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -171,7 +171,7 @@ print ''; print ''; print ''; -dol_fiche_head($head, 'general', $langs->trans("Configuration"), 0, 'cron'); +dol_fiche_head($head, 'general', $langs->trans("Configuration"), -1, 'cron'); // Default mode for calculating turnover (parameter ACCOUNTING_MODE) @@ -299,7 +299,7 @@ print '
transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")); +print '
'.$langs->trans("AccountancySetupDoneFromAccountancyMenu", $langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")).'
'; print '
'; print ''; diff --git a/htdocs/accountancy/admin/journals.php b/htdocs/accountancy/admin/journals.php index 03b51089d9a..677f2a743e5 100644 --- a/htdocs/accountancy/admin/journals.php +++ b/htdocs/accountancy/admin/journals.php @@ -94,7 +94,7 @@ print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'titl $head = admin_accounting_prepare_head(null); -dol_fiche_head($head, 'journal', $langs->trans("Configuration"), 0, 'cron'); +dol_fiche_head($head, 'journal', $langs->trans("Configuration"), -1, 'cron'); $sql = "SELECT j.rowid, j.code, j.label, j.nature, j.active"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_journal as j"; From 853c8a8e07661edce38393dc2e31d9bbd81baf61 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Apr 2017 18:05:53 +0200 Subject: [PATCH 30/34] Fix typo --- htdocs/langs/en_US/sendings.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index ef6fe44856b..ac180cb5fe6 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -53,7 +53,7 @@ ShipmentCreationIsDoneFromOrder=For the moment, creation of a new shipment is do ShipmentLine=Shipment line ProductQtyInCustomersOrdersRunning=Product quantity into open customers orders ProductQtyInSuppliersOrdersRunning=Product quantity into open suppliers orders -ProductQtyInShipmentAlreadySent=Product quantity from oped customer order already sent +ProductQtyInShipmentAlreadySent=Product quantity from open customer order already sent ProductQtyInSuppliersShipmentAlreadyRecevied=Product quantity from open supplier order already received NoProductToShipFoundIntoStock=No product to ship found into warehouse %s. Correct stock or go back to choose another warehouse. WeightVolShort=Weight/Vol. From 0ba6433a6166853b4b8a7a4d019c0b9e29a2b68f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Apr 2017 13:10:08 +0200 Subject: [PATCH 31/34] Work on module website --- htdocs/admin/websites.php | 49 +++++-------- .../install/mysql/migration/5.0.0-6.0.0.sql | 3 + htdocs/install/mysql/tables/llx_website.sql | 7 +- .../mysql/tables/llx_website_pages.sql | 6 +- htdocs/langs/en_US/website.lang | 4 +- htdocs/theme/eldy/img/save.png | Bin 0 -> 264 bytes htdocs/theme/md/img/save.png | Bin 0 -> 264 bytes htdocs/websites/class/website.class.php | 47 +++++------- htdocs/websites/class/websitepage.class.php | 13 ++-- htdocs/websites/index.php | 68 +++++++++++++----- 10 files changed, 105 insertions(+), 92 deletions(-) create mode 100644 htdocs/theme/eldy/img/save.png create mode 100644 htdocs/theme/md/img/save.png diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index b0c81ec18af..06e9a7b93a4 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -375,11 +375,11 @@ if ($id) // dans les dictionnaires de donnees $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=$langs->trans($valuetoshow); // try to translate - $align="left"; + $align=''; if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($valuetoshow != '') { - print ''; + print ''; if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print '
'.$valuetoshow.' '.img_help(1,$valuetoshow).''; else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]); else print $valuetoshow; @@ -413,14 +413,11 @@ if ($id) $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; - if ($id == 3) unset($fieldlist[2]); - if (empty($reshook)) { fieldListWebsites($fieldlist,$obj,$tabname[$id],'add'); } - if ($id == 4) print ''; print ''; if ($action != 'edit') { @@ -430,15 +427,9 @@ if ($id) print ""; $colspan=count($fieldlist)+2; - if ($id == 4) $colspan++; - - if (! empty($alabelisused) && $id != 25) // If there is one label among fields, we show legend of * - { - print '* '.$langs->trans("LabelUsedByDefault").'.'; - } - print ' '; // Keep   to have a line with enough height } + print ''; print ''; @@ -453,6 +444,15 @@ if ($id) $var=true; if ($num) { + print '
'; + + print '
'; + print ''; + print ''; + print ''; + + print ''; + // There is several pages if ($num > $listlimit) { @@ -503,14 +503,9 @@ if ($id) $obj = $db->fetch_object($resql); //print_r($obj); - print ''; + print ''; if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) { - print ''; - print ''; - print ''; - print ''; - $tmpaction='edit'; $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks @@ -548,16 +543,6 @@ if ($id) $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&id='.$id.'&'; - // Favorite - // Only activated on country dictionary - if ($id == 4) - { - print ''; - } - // Active print '
'; - if ($iserasable) print ''.$actl[$obj->favorite].''; - else print $langs->trans("AlwaysActive"); - print ''; print ''.$actl[$obj->status].''; @@ -575,15 +560,15 @@ if ($id) } $i++; } + + print '
'; + + print '
'; } } else { dol_print_error($db); } - - print ''; - - print ''; } print '
'; diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 9ff9de4e70d..c2edae8b592 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -137,6 +137,9 @@ ALTER TABLE llx_chargesociales ADD COLUMN fk_projet integer DEFAULT NULL; ALTER TABLE llx_cronjob ADD COLUMN processing integer NOT NULL DEFAULT 0; +ALTER TABLE llx_website ADD COLUMN fk_user_create integer; +ALTER TABLE llx_website ADD COLUMN fk_user_modif integer; + create table llx_payment_various ( diff --git a/htdocs/install/mysql/tables/llx_website.sql b/htdocs/install/mysql/tables/llx_website.sql index 331e6b085bd..84a9dd47188 100644 --- a/htdocs/install/mysql/tables/llx_website.sql +++ b/htdocs/install/mysql/tables/llx_website.sql @@ -26,7 +26,8 @@ CREATE TABLE llx_website status integer, fk_default_home integer, virtualhost varchar(255), - date_creation datetime, - date_modification datetime, - tms timestamp + fk_user_create integer, + fk_user_modif integer, + date_creation datetime, + tms timestamp ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_website_pages.sql b/htdocs/install/mysql/tables/llx_website_pages.sql index 982420dd507..69b6c417528 100644 --- a/htdocs/install/mysql/tables/llx_website_pages.sql +++ b/htdocs/install/mysql/tables/llx_website_pages.sql @@ -27,6 +27,8 @@ CREATE TABLE llx_website_page keywords varchar(255), content mediumtext, -- text is not enough in size status integer, - date_creation datetime, - tms timestamp + fk_user_create integer, + fk_user_modif integer, + date_creation datetime, + tms timestamp ) ENGINE=innodb; diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index fcb09c8d5c1..03069d6f649 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -24,5 +24,5 @@ SetAsHomePage=Set as Home page RealURL=Real URL ViewWebsiteInProduction=View web site using home URLs SetHereVirtualHost=If you can set, on your web server, a dedicated virtual host with a root directory on %s, define here the virtual hostname so the preview can be done also using this direct web server access and not only using Dolibarr server. -PreviewSiteServedByWebServer=Preview %s in a new tab. The %s will be served by an external web server (like Apache, Nginx, IIS). You must instal and setup this server before.
URL of %s served by external server:
%s -PreviewSiteServedByDolibarr=Preview %s in a new tab. The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.
URL of %s served by Dolibarr:
%s +PreviewSiteServedByWebServer=Preview %s in a new tab.

The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:
%s
URL served by external server:
%s +PreviewSiteServedByDolibarr=Preview %s in a new tab.

The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.
URL served by Dolibarr:
%s

To use your own external web server to serve this web site, create a virtual host on your web server that point on directory
%s
then enter the name of this virtual server and clicking on the other preview button. diff --git a/htdocs/theme/eldy/img/save.png b/htdocs/theme/eldy/img/save.png new file mode 100644 index 0000000000000000000000000000000000000000..eca2d92eccc5665b070d3c04e7241fbc2cbb71d5 GIT binary patch literal 264 zcmV+j0r&oiP)^5To~qfUqA&PMF*F<|kx;Md$&W&;x!#4;TRufSvnyKmY=;&`=O< zD`{EPz!xd^WlTz7A;m7|q5~RSbvmHHRiy(WT*Yq$l(?#OK#Qwh2dre+9fV)gZ4fyZ>#A&pWX|cF@nuJ>{9{^+CL!nen`MaoS0vDoPmT;NZb{N*U=t-36Ko{ O0000^5To~qfUqA&PMF*F<|kx;Md$&W&;x!#4;TRufSvnyKmY=;&`=O< zD`{EPz!xd^WlTz7A;m7|q5~RSbvmHHRiy(WT*Yq$l(?#OK#Qwh2dre+9fV)gZ4fyZ>#A&pWX|cF@nuJ>{9{^+CL!nen`MaoS0vDoPmT;NZb{N*U=t-36Ko{ O0000entity)) { $this->entity = trim($this->entity); } @@ -136,36 +131,30 @@ class Website extends CommonObject if (isset($this->status)) { $this->status = trim($this->status); } - - + if (empty($this->date_creation)) $this->date_creation = dol_now(); // Check parameters // Put here code to add control on parameters values // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - $sql.= 'entity,'; $sql.= 'ref,'; $sql.= 'description,'; $sql.= 'status,'; $sql.= 'fk_default_home,'; $sql.= 'virtualhost,'; - $sql.= 'date_creation,'; - $sql.= 'date_modification'; - + $sql.= 'fk_user_create'; + $sql.= 'date_creation'; $sql .= ') VALUES ('; - $sql .= ' '.(! isset($this->entity)?'NULL':$this->entity).','; $sql .= ' '.(! isset($this->ref)?'NULL':"'".$this->db->escape($this->ref)."'").','; $sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").','; $sql .= ' '.(! isset($this->status)?'NULL':$this->status).','; $sql .= ' '.(! isset($this->fk_default_home)?'NULL':$this->fk_default_home).','; $sql .= ' '.(! isset($this->virtualhost)?'NULL':$this->virtualhost).','; - $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").','; - $sql .= ' '.(! isset($this->date_modification) || dol_strlen($this->date_modification)==0?'NULL':"'".$this->db->idate($this->date_modification)."'"); - - + $sql .= ' '.(! isset($this->fk_user_create)?$user->id:$this->fk_user_create).','; + $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'"); $sql .= ')'; $this->db->begin(); @@ -223,8 +212,9 @@ class Website extends CommonObject $sql .= " t.status,"; $sql .= " t.fk_default_home,"; $sql .= " t.virtualhost,"; + $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; - $sql .= " t.date_modification,"; $sql .= " t.tms"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; if (null !== $ref) { @@ -247,11 +237,10 @@ class Website extends CommonObject $this->status = $obj->status; $this->fk_default_home = $obj->fk_default_home; $this->virtualhost = $obj->virtualhost; + $this->fk_user_create = $obj->fk_user_create; + $this->fk_user_modif = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date_modification = $this->db->jdate($obj->date_modification); $this->tms = $this->db->jdate($obj->tms); - - } $this->db->free($resql); @@ -292,8 +281,9 @@ class Website extends CommonObject $sql .= " t.status,"; $sql .= " t.fk_default_home,"; $sql .= " t.virtualhost,"; + $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; - $sql .= " t.date_modification,"; $sql .= " t.tms"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; @@ -331,8 +321,9 @@ class Website extends CommonObject $line->status = $obj->status; $line->fk_default_home = $obj->fk_default_home; $line->virtualhost = $obj->virtualhost; + $this->fk_user_create = $obj->fk_user_create; + $this->fk_user_modif = $obj->fk_user_modif; $line->date_creation = $this->db->jdate($obj->date_creation); - $line->date_modification = $this->db->jdate($obj->date_modification); $line->tms = $this->db->jdate($obj->tms); $this->records[$line->id] = $line; @@ -377,25 +368,20 @@ class Website extends CommonObject $this->status = trim($this->status); } - - // Check parameters // Put here code to add a control on parameters values // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - $sql .= ' entity = '.(isset($this->entity)?$this->entity:"null").','; $sql .= ' ref = '.(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").','; $sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").','; $sql .= ' status = '.(isset($this->status)?$this->status:"null").','; $sql .= ' fk_default_home = '.(($this->fk_default_home > 0)?$this->fk_default_home:"null").','; $sql .= ' virtualhost = '.(($this->virtualhost != '')?"'".$this->db->escape($this->virtualhost)."'":"null").','; + $sql .= ' fk_user_modif = '.(! isset($this->fk_user_modif) ? $user->id : $this->fk_user_modif).','; $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; - $sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'"); - - $sql .= ' WHERE rowid=' . $this->id; $this->db->begin(); @@ -631,6 +617,8 @@ class Website extends CommonObject */ public function initAsSpecimen() { + global $user; + $this->id = 0; $this->entity = 1; @@ -639,8 +627,9 @@ class Website extends CommonObject $this->status = ''; $this->fk_default_home = null; $this->virtualhost = 'http://myvirtualhost'; + $this->fk_user_create = $user->id; + $this->fk_user_modif = $user->id; $this->date_creation = dol_now(); - $this->date_modification = dol_now(); $this->tms = dol_now(); diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 883b6495c53..c80d20fe44b 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -181,7 +181,7 @@ class WebsitePage extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object + * @param int $id Id object. If this is 0, the default page of website_id will be used, if not defined, the first one. found * @param string $website_id Web site id * @param string $page Page name * @@ -205,13 +205,16 @@ class WebsitePage extends CommonObject $sql .= " t.tms as date_modification"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + //$sql .= ' WHERE entity IN ('.getEntity('website', 1).')'; // entity is on website level + $sql .= ' WHERE 1 = 1'; if (null !== $website_id) { - $sql .= ' WHERE t.fk_website = ' . '\'' . $website_id . '\''; - $sql .= ' AND t.pageurl = ' . '\'' . $page . '\''; + $sql .= " AND t.fk_website = '" . $this->db->escape($website_id) . "'"; + if ($page) $sql .= " AND t.pageurl = '" . $this->db->escape($page) . "'"; } else { - $sql .= ' WHERE t.rowid = ' . $id; + $sql .= ' AND t.rowid = ' . $id; } - + $sql .= $this->db->plimit(1); + $resql = $this->db->query($sql); if ($resql) { $numrows = $this->db->num_rows($resql); diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index b55f81f5b7f..b78a172e01f 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -438,16 +438,34 @@ if ($action == 'updatemeta') // Update page if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview')) { - $db->begin(); $object->fetch(0, $website); + /*if (GETPOST('savevirtualhost') && $object->virtualhost != GETPOST('previewsite')) + { + $object->virtualhost = GETPOST('previewsite', 'alpha'); + $object->update($user); + }*/ + $objectpage->fk_website = $object->id; - $res = $objectpage->fetch($pageid, $object->fk_website); + if ($pageid > 0) + { + $res = $objectpage->fetch($pageid); + } + else + { + $res = $objectpage->fetch($object->fk_default_home); + if (! $res > 0) + { + $res = $objectpage->fetch(0, $object->fk_website); + } + } if ($res > 0) { if ($action == 'updatecontent') { + $db->begin(); + $objectpage->content = GETPOST('PAGE_CONTENT'); // Clean data. We remove all the head section. @@ -632,7 +650,7 @@ if (count($object->records) > 0) // List of websites print '
'; $out=''; - $out.=''; if (empty($object->records)) $out.=''; // Loop on each sites $i=0; @@ -654,9 +672,9 @@ if (count($object->records) > 0) if ($website) { - $realurl=$urlwithroot.'/public/websites/index.php?website='.$website; + $virtualurl=''; $dataroot=DOL_DATA_ROOT.'/websites/'.$website; - if (! empty($object->virtualhost)) $realurl=$object->virtualhost; + if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost; } if ($website && $action == 'preview') @@ -680,20 +698,23 @@ if (count($object->records) > 0) if ($action == 'preview') { print '
'; - print ''; + print ''; //print ''; $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); print $form->textwithpicto('', $htmltext); print '
'; - $urlext=$realurl; - $urlint=DOL_URL_ROOT.'/public/websites/index.php?website='.$website; - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $urlext), 1, 'preview_ext'); - print ''; + $urlext=$virtualurl; + $urlint=$urlwithroot.'/public/websites/index.php?website='.$website; + //if (! empty($object->virtualhost)) + //{ + print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; + //} - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $urlint), 1, 'preview'); + print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); print ''; } @@ -803,13 +824,22 @@ if (count($object->records) > 0) print $form->textwithpicto('', $htmltext); print '
'; - $urlext=$realurl.'/'.$pagealias.'.php'; - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $urlext), 1, 'preview_ext'); - print ''; + if (! empty($object->virtualhost)) + { + $urlext=$virtualurl.'/'.$pagealias.'.php'; + print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; + } + else + { + print ''; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; + } - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage), 1, 'preview'); + print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); print ''; // View page in new Tab //print ''; From c722286bcb584868d7603f16571299fa327c04a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Apr 2017 13:37:36 +0200 Subject: [PATCH 32/34] Fix regressions --- htdocs/comm/card.php | 2 +- htdocs/compta/facture/card.php | 2 +- htdocs/core/class/html.form.class.php | 2 +- htdocs/langs/en_US/main.lang | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 67ab40f4946..aae1398109d 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1098,7 +1098,7 @@ if ($id > 0) else print ''; } - if ($object->client != 0 && $object->client != 2) print ''; + if ($object->client != 0 && $object->client != 2) print ''; else print ''; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6e8c3b6d895..70eea532a79 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2191,7 +2191,7 @@ if ($action == 'create') else { print ''; - print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty'); + print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // Option to reload page to retrieve customer informations. Note, this clear other input if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b839e46dc8b..3275ee0f303 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -994,7 +994,7 @@ class Form print img_picto($langs->trans("Search"), 'search'); } } - print 'global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; + print 'global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; if ($hidelabel == 3) { print img_picto($langs->trans("Search"), 'search'); } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 71788071a2d..1a3eea413df 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -823,5 +823,5 @@ SearchIntoContracts=Contracts SearchIntoCustomerShipments=Customer shipments SearchIntoExpenseReports=Expense reports SearchIntoLeaves=Leaves - +SetMultiCurrencyCode=Set currency BulkActions=Bulk actions \ No newline at end of file From defce63a24456d2f57e14bdfa09faa282ed138aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Apr 2017 14:05:28 +0200 Subject: [PATCH 33/34] Work on management of default values --- htdocs/admin/defaultvalues.php | 9 ++++--- htdocs/core/lib/functions.lib.php | 43 ++++++++++++++++++++++++------- htdocs/langs/en_US/admin.lang | 2 +- htdocs/master.inc.php | 2 +- htdocs/user/class/user.class.php | 4 +-- 5 files changed, 42 insertions(+), 18 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 0bc620c41bf..96fef57e7cf 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -187,29 +187,30 @@ $texthelp=$langs->trans("PageUrlForDefaultValues"); if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php'); else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php'); $texturl=$form->textwithpicto($langs->trans("Url"), $texthelp); -print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'defaulturl','',$param,'',$sortfield,$sortorder); +print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'page,param','',$param,'',$sortfield,$sortorder); $texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField"); if ($mode != 'sortorder') $textkey=$form->textwithpicto($langs->trans("Key"), $texthelp); else $textkey=$form->textwithpicto($langs->trans("Key"), $texthelp); -print_liste_field_titre($textkey,$_SERVER["PHP_SELF"],'defaultkey','',$param,'',$sortfield,$sortorder); +print_liste_field_titre($textkey,$_SERVER["PHP_SELF"],'param','',$param,'',$sortfield,$sortorder); if ($mode != 'sortorder') { $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
'; // See list into GETPOST $texthelp.='__USERID__
'; + $texthelp.='__SUPERVISORID__
'; $texthelp.='__MYCOUNTRYID__
'; $texthelp.='__DAY__
'; $texthelp.='__MONTH__
'; $texthelp.='__YEAR__
'; if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__
'; - $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp); + $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); } else { $texthelp='ASC or DESC'; $textvalue=$form->textwithpicto($langs->trans("SortOrder"), $texthelp); } -print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'defaultvalue', '', $param, '', $sortfield, $sortorder); +print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder); if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,page','',$param,'',$sortfield,$sortorder); print ''; print "\n"; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d430a8ea53b..7743da27c2d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -253,17 +253,35 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:''); // Management of default values - if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + if (! isset($_GET['sortfield'])) // If we did a click on a field so sort, we do no appl default values { - $relativepathstring = preg_replace('/\.[a-z]+$/', '', $_SERVER["PHP_SELF"]); - if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); - $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); - $relativepathstring = preg_replace('/^\//', '', $relativepathstring); - $relativepathstring=dol_string_nospecial($relativepathstring, '-'); - // $relativepathstring is now string that identify the page: '_societe_card', '_agenda_card', ... - $keyfordefaultvalue = 'MAIN_DEFAULT_FOR_'.$relativepathstring.'_'.$paramname; - global $conf; - if (isset($conf->global->$keyfordefaultvalue)) $out = $conf->global->$keyfordefaultvalue; + if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + { + $relativepathstring = $_SERVER["PHP_SELF"]; + if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^\//', '', $relativepathstring); + global $user; + if (! empty($user->default_values)) // $user->default_values defined from menu default values, and values loaded not at first + { + //var_dump($user->default_values[$relativepathstring]['createform']); + if (isset($user->default_values[$relativepathstring]['createform'][$paramname])) $out = $user->default_values[$relativepathstring]['createform'][$paramname]; + } + } + // Management of default search_filters + elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + { + $relativepathstring = $_SERVER["PHP_SELF"]; + if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^\//', '', $relativepathstring); + global $user; + if (! empty($user->default_values)) // $user->default_values defined from menu default values, and values loaded not at first + { + //var_dump($user->default_values[$relativepathstring]); + if (isset($user->default_values[$relativepathstring]['filters'][$paramname])) $out = $user->default_values[$relativepathstring]['filters'][$paramname]; + } + } } } elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:''; @@ -303,6 +321,11 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) global $user; $out = $user->id; } + elseif ($reg[1] == 'SUPERVISORID') + { + global $user; + $out = $user->fk_user; + } elseif ($reg[1] == 'ENTITYID') { global $conf; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index af23343398b..1bfa5c0230c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -428,7 +428,7 @@ ClickToShowDescription=Click to show description DependsOn=This module need the module(s) RequiredBy=This module is required by module(s) TheKeyIsTheNameOfHtmlField=The key is the name of the html field. This need to have technical knowledges to read the content of the HTML page to get the key name of a field. -PageUrlForDefaultValues=You must enter here the relative url of the page. Examples: +PageUrlForDefaultValues=You must enter here the relative url of the page. If you include parameters in URL, the default values will be effective if all parameters are set to same value. Examples: PageUrlForDefaultValuesCreate=
For form to create a new thirdparty, it is %s PageUrlForDefaultValuesList=
For page that list thirdparties, it is %s GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code, so to change this value, you must edit it fom Home-Setup-translation. diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index ebb99eb9807..61e51999479 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -180,7 +180,7 @@ if (! defined('NOREQUIREDB')) //print "Will work with data into entity instance number '".$conf->entity."'"; - // Here we read database (llx_const table and llx_default_values) and define $conf->global->XXX var. + // Here we read database (llx_const table) and define $conf->global->XXX var. $conf->setValues($db); } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index a3006d6ebcd..f23c8aca0b6 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -376,7 +376,7 @@ class User extends CommonObject { if (! empty($obj->page) && ! empty($obj->type) && ! empty($obj->param)) { - $user->default_values[$obj->page][$obj->type][$obj->param]=$obj->value; + $this->default_values[$obj->page][$obj->type][$obj->param]=$obj->value; } } $this->db->free($resql); @@ -387,7 +387,7 @@ class User extends CommonObject return -3; } } - + return 1; } From 2e6d865c7d07b48254228cba07e082d42a53ed28 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Apr 2017 00:44:25 +0200 Subject: [PATCH 34/34] NEW Can define default values for create forms. NEW Can define default filters for list pages. NEW Can define default sort order for list pages. --- htdocs/admin/defaultvalues.php | 95 +++++++++++++++++++++++++------ htdocs/admin/dict.php | 2 +- htdocs/core/db/DoliDB.class.php | 17 ++++-- htdocs/core/lib/functions.lib.php | 53 ++++++++++++----- htdocs/langs/en_US/admin.lang | 4 +- htdocs/theme/eldy/style.css.php | 2 +- 6 files changed, 135 insertions(+), 38 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 96fef57e7cf..8a9bd4f209b 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -56,6 +56,10 @@ $defaultvalue = GETPOST('defaultvalue'); $defaulturl=preg_replace('/^\//', '', $defaulturl); +$urlpage = GETPOST('urlpage'); +$key = GETPOST('key'); +$value = GETPOST('value'); + /* * Actions @@ -81,25 +85,51 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP } -if ($action == 'add' || (GETPOST('add') && $action != 'update')) +if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) { $error=0; - if (empty($defaulturl)) + if (($action == 'add' || (GETPOST('add') && $action != 'update'))) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); - $error++; + if (empty($defaulturl)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); + $error++; + } + if (empty($defaultkey)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); + $error++; + } } - if (empty($defaultkey)) + if (GETPOST('actionmodify')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Key")), null, 'errors'); - $error++; + if (empty($urlpage)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); + $error++; + } + if (empty($key)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); + $error++; + } } + if (! $error) { $db->begin(); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")"; + + if ($action == 'add' || (GETPOST('add') && $action != 'update')) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")"; + } + if (GETPOST('actionmodify')) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'"; + $sql.= " WHERE rowid = ".$id; + } + $result = $db->query($sql); if ($result > 0) { @@ -176,6 +206,10 @@ $head=defaultvalues_prepare_head(); dol_fiche_head($head, $mode, '', -1, ''); +if ($mode == 'sortorder') +{ + print info_admin($langs->trans("WarningSettingSortOrder")).'
'; +} print ''; print ''; @@ -189,8 +223,15 @@ else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php') $texturl=$form->textwithpicto($langs->trans("Url"), $texthelp); print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'page,param','',$param,'',$sortfield,$sortorder); $texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField"); -if ($mode != 'sortorder') $textkey=$form->textwithpicto($langs->trans("Key"), $texthelp); -else $textkey=$form->textwithpicto($langs->trans("Key"), $texthelp); +if ($mode != 'sortorder') +{ + $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); +} +else +{ + $texthelp='field or alias.field'; + $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); +} print_liste_field_titre($textkey,$_SERVER["PHP_SELF"],'param','',$param,'',$sortfield,$sortorder); if ($mode != 'sortorder') { @@ -270,9 +311,17 @@ if ($result) print ''; - print ''.$obj->page.''."\n"; - print ''.$obj->param.''."\n"; - + print ''; + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->page; + else print ''; + print ''."\n"; + + // Key + print ''; + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param; + else print ''; + print ''."\n"; + // Value print ''; /*print ''; @@ -280,11 +329,25 @@ if ($result) print ''; print ''; */ - print $obj->value; + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->value; + else print ''; print ''; print ''; - print ''.img_delete().''; + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) + { + print ''.img_edit().''; + print '   '; + print ''.img_delete().''; + } + else + { + print ''; + print ''; + print '
'; + print ''; + print ''; + } print ''; print "\n"; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index c8632f57772..125f913eb8d 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1306,10 +1306,10 @@ if ($id) if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit'); print ''; + print '
'; print ''; print ''; print ''; - print '
'; print ''; print ''; } diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index c63227e1601..9fc1739334c 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -220,9 +220,9 @@ abstract class DoliDB implements Database /** * Define sort criteria of request * - * @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda, t2.fieldb' + * @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda, t2.fieldb' * @param 'ASC'|'DESC' $sortorder Sort order - * @return string String to provide syntax of a sort sql string + * @return string String to provide syntax of a sort sql string */ function order($sortfield=null,$sortorder=null) { @@ -230,18 +230,25 @@ abstract class DoliDB implements Database { $return=''; $fields=explode(',',$sortfield); + $orders=explode(',',$sortorder); + $i=0; foreach($fields as $val) { if (! $return) $return.=' ORDER BY '; - else $return.=','; + else $return.=', '; $return.=preg_replace('/[^0-9a-z_\.]/i','',$val); + + $tmpsortorder = trim($orders[$i]); + // Only ASC and DESC values are valid SQL - if (strtoupper($sortorder) === 'ASC') { + if (strtoupper($tmpsortorder) === 'ASC') { $return .= ' ASC'; - } elseif (strtoupper($sortorder) === 'DESC') { + } elseif (strtoupper($tmpsortorder) === 'DESC') { $return .= ' DESC'; } + + $i++; } return $return; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7743da27c2d..0d54593f0db 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -246,16 +246,16 @@ function dol_shutdown() * @param mixed $options Options to pass to filter_var when $check is set to custom * @return string|string[] Value found (string or array), or '' if check fails */ -function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) +function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL) { if (empty($method)) { $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:''); - + // Management of default values - if (! isset($_GET['sortfield'])) // If we did a click on a field so sort, we do no appl default values + if (! isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values { - if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) { $relativepathstring = $_SERVER["PHP_SELF"]; if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); @@ -268,18 +268,40 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) if (isset($user->default_values[$relativepathstring]['createform'][$paramname])) $out = $user->default_values[$relativepathstring]['createform'][$paramname]; } } - // Management of default search_filters + // Management of default search_filters and sort order elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) { - $relativepathstring = $_SERVER["PHP_SELF"]; + $relativepathstring = $_SERVER["PHP_SELF"]; if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); $relativepathstring = preg_replace('/^\//', '', $relativepathstring); global $user; if (! empty($user->default_values)) // $user->default_values defined from menu default values, and values loaded not at first { - //var_dump($user->default_values[$relativepathstring]); - if (isset($user->default_values[$relativepathstring]['filters'][$paramname])) $out = $user->default_values[$relativepathstring]['filters'][$paramname]; + //var_dump($user->default_values[$relativepathstring]); + if ($paramname == 'sortfield') + { + if (isset($user->default_values[$relativepathstring]['sortorder'])) + { + foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val) + { + if ($out) $out.=', '; + $out.=$key; + } + } + } + elseif ($paramname == 'sortorder') + { + if (isset($user->default_values[$relativepathstring]['sortorder'])) + { + foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val) + { + if ($out) $out.=', '; + $out.=$val; + } + } + } + elseif (isset($user->default_values[$relativepathstring]['filters'][$paramname])) $out = $user->default_values[$relativepathstring]['filters'][$paramname]; } } } @@ -3178,6 +3200,9 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m $tag='th'; if ($thead==2) $tag='div'; + $tmpsortfield=explode(',',$sortfield); + $sortfield=trim($tmpsortfield[0]); + // If field is used as sort criteria we use a specific class // Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom") if ($field && ($sortfield == $field || $sortfield == preg_replace("/^[^\.]+\./","",$field))) $out.= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '. $moreattrib.'>'; @@ -3192,13 +3217,13 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m if ($field != $sortfield) { - if ($sortorder == 'DESC') $out.= ''; - if ($sortorder == 'ASC' || ! $sortorder) $out.= ''; + if (preg_match('/^DESC/', $sortorder)) $out.= ''; + else $out.= ''; } else { - if ($sortorder == 'DESC' || ! $sortorder) $out.= ''; - if ($sortorder == 'ASC') $out.= ''; + if (preg_match('/^ASC/', $sortorder)) $out.= ''; + else $out.= ''; } } @@ -3227,12 +3252,12 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m } else { - if ($sortorder == 'DESC' ) { + if (preg_match('/^DESC/', $sortorder)) { //$out.= ''.img_down("A-Z",0).''; //$out.= ''.img_up("Z-A",1).''; $sortimg.= ''.img_up("Z-A",0).''; } - if ($sortorder == 'ASC' ) { + if (preg_match('/^ASC/', $sortorder)) { //$out.= ''.img_down("A-Z",1).''; //$out.= ''.img_up("Z-A",0).''; $sortimg.= ''.img_down("A-Z",0).''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1bfa5c0230c..69c72fc7aad 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -427,11 +427,13 @@ WarningPHPMail=WARNING: Some email providers (like Yahoo) does not allow you to ClickToShowDescription=Click to show description DependsOn=This module need the module(s) RequiredBy=This module is required by module(s) -TheKeyIsTheNameOfHtmlField=The key is the name of the html field. This need to have technical knowledges to read the content of the HTML page to get the key name of a field. +TheKeyIsTheNameOfHtmlField=This is the name of the HTML field. This need to have technical knowledges to read the content of the HTML page to get the key name of a field. PageUrlForDefaultValues=You must enter here the relative url of the page. If you include parameters in URL, the default values will be effective if all parameters are set to same value. Examples: PageUrlForDefaultValuesCreate=
For form to create a new thirdparty, it is %s PageUrlForDefaultValuesList=
For page that list thirdparties, it is %s GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code, so to change this value, you must edit it fom Home-Setup-translation. +WarningSettingSortOrder=Warning, setting a default sort order may result in a technical error when going on the list page if field is an unknown field. If you experience such an error, come back to this page to remove the default sort order to retreive default behavior. +Field=Field # Modules Module0Name=Users & groups Module0Desc=Users / Employees and Groups management diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index f0e615f29ce..4d711599992 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -253,7 +253,7 @@ a.tab { font-weight: bold !important; } a:link, a:visited, a:hover, a:active { font-family: ; font-weight: normal; color: rgb(); text-decoration: none; } a:hover { text-decoration: underline; color: rgb(); } a.commonlink { color: rgb() !important; text-decoration: none; } - +th.liste_titre a div div:hover, th.liste_titre_sel a div div:hover { text-decoration: underline; } input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select { background-color: #FFF; }