From 6d70d39bbda227abcbb8935e256bd14112a61a25 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 8 Nov 2016 17:21:26 +0100 Subject: [PATCH] NEW Add type "url" as possible extrafield. --- htdocs/admin/supplier_order.php | 2 +- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/compta/facture/apercu.php | 4 +- htdocs/compta/facture/prelevement.php | 4 +- htdocs/core/class/extrafields.class.php | 29 +++++++++----- htdocs/core/class/html.form.class.php | 38 +++++++++++-------- .../core/tpl/admin_extrafields_edit.tpl.php | 8 ++-- htdocs/expedition/shipment.php | 2 +- htdocs/langs/en_US/admin.lang | 3 +- htdocs/public/test/test_arrays.php | 1 - htdocs/public/test/test_forms.php | 3 +- 12 files changed, 58 insertions(+), 40 deletions(-) diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 5d0cf665d7c..5c288b9e78a 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -497,7 +497,7 @@ $var=false; print $form->textwithpicto($langs->trans("UseDoubleApproval"), $langs->trans("Use3StepsApproval"), 1, 'help').'
'; print $langs->trans("IfSetToYesDontForgetPermission"); print ''; - print ''; + print ''; print ''; print ''; print "\n"; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 6b47d5205b6..5af6fbe3733 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1808,7 +1808,7 @@ if ($action == 'create') // Remise dispo de type non avoir $filter = 'fk_facture_source IS NULL'; print '
'; - $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $soc->id, $absolute_discount, $filter); + $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $soc->id, $absolute_discount, $filter, 0, '', 1); } } if ($absolute_creditnote) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 313fef16e2c..e0e569a99b2 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2019,7 +2019,7 @@ if ($action == 'create' && $user->rights->commande->creer) } else { // Remise dispo de type remise fixe (not credit note) print '
'; - $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount); + $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, 0, '', 1); } } if ($absolute_creditnote) { diff --git a/htdocs/compta/facture/apercu.php b/htdocs/compta/facture/apercu.php index 8300545cb22..258b2434f60 100644 --- a/htdocs/compta/facture/apercu.php +++ b/htdocs/compta/facture/apercu.php @@ -188,7 +188,7 @@ if ($id > 0 || ! empty($ref)) // Remise dispo de type remise fixe (not credit note) $filter='fk_facture_source IS NULL'; print '
'; - $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id',$soc->id, $absolute_discount, $filter, $resteapayer, ' - '.$addabsolutediscount); + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id',$soc->id, $absolute_discount, $filter, $resteapayer, ' - '.$addabsolutediscount, 1); } } else @@ -220,7 +220,7 @@ if ($id > 0 || ! empty($ref)) // Remise dispo de type avoir $filter='fk_facture_source IS NOT NULL'; if (! $absolute_discount) print '
'; - $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filter, $resteapayer); + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filter, $resteapayer, '', 1); } } if (! $absolute_discount && ! $absolute_creditnote) diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 87a27166ae8..879d5abfee4 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -263,7 +263,7 @@ if ($object->id > 0) // Remise dispo de type non avoir $filter='fk_facture_source IS NULL'; print '
'; - $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id',$object->thirdparty->id,$absolute_discount,$filter,$resteapayer); + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id',$object->thirdparty->id,$absolute_discount,$filter,$resteapayer,'',1); } } if ($absolute_creditnote > 0) @@ -283,7 +283,7 @@ if ($object->id > 0) // Remise dispo de type avoir $filter='fk_facture_source IS NOT NULL'; if (! $absolute_discount) print '
'; - $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id_for_payment',$object->thirdparty->id,$absolute_creditnote,$filter,$resteapayer); + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id_for_payment',$object->thirdparty->id,$absolute_creditnote,$filter,$resteapayer,'',1); } } if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 9bed1ed9a82..5034be1c901 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -76,14 +76,15 @@ class ExtraFields 'price'=>'ExtrafieldPrice', 'phone'=>'ExtrafieldPhone', 'mail'=>'ExtrafieldMail', + 'url'=>'ExtrafieldUrl', 'select' => 'ExtrafieldSelect', 'sellist' => 'ExtrafieldSelectList', 'radio' => 'ExtrafieldRadio', 'checkbox' => 'ExtrafieldCheckBox', 'chkbxlst' => 'ExtrafieldCheckBoxFromList', 'link' => 'ExtrafieldLink', - 'separate' => 'ExtrafieldSeparator', 'password' => 'ExtrafieldPassword', + 'separate' => 'ExtrafieldSeparator', ); /** @@ -195,6 +196,9 @@ class ExtraFields } elseif($type=='mail') { $typedb='varchar'; $lengthdb='128'; + } elseif($type=='url') { + $typedb='varchar'; + $lengthdb='255'; } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') ||($type=='checkbox') ||($type=='chkbxlst')){ $typedb='text'; $lengthdb=''; @@ -425,6 +429,9 @@ class ExtraFields } elseif($type=='mail') { $typedb='varchar'; $lengthdb='128'; + } elseif($type=='url') { + $typedb='varchar'; + $lengthdb='255'; } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') || ($type=='checkbox') || ($type=='chkbxlst')) { $typedb='text'; $lengthdb=''; @@ -693,6 +700,10 @@ class ExtraFields //$showsize=10; $showsize = 'minwidth100imp'; } + elseif ($type == 'url') + { + $showsize='minwidth400imp'; + } else { if (round($size) < 12) @@ -738,6 +749,10 @@ class ExtraFields { $out=''; } + elseif (in_array($type, array('mail', 'phone', 'url'))) + { + $out=''; + } elseif ($type == 'text') { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -754,14 +769,6 @@ class ExtraFields } $out=''; } - elseif ($type == 'mail') - { - $out=''; - } - elseif ($type == 'phone') - { - $out=''; - } elseif ($type == 'price') { $out=' '.$langs->getCurrencySymbol($conf->currency); @@ -1238,6 +1245,10 @@ class ExtraFields { $value=dol_print_email($value); } + elseif ($type == 'url') + { + $value=dol_print_url($value,'_blank',32,1); + } elseif ($type == 'phone') { $value=dol_print_phone($value); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b3e1c162102..b5fc9fbc560 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3910,15 +3910,16 @@ class Form * * @param string $page Page URL where form is shown * @param int $selected Value pre-selected - * @param string $htmlname Nom du formulaire select. Si 'none', non modifiable. Example 'remise_id'. + * @param string $htmlname Name of SELECT component. If 'none', not changeable. Example 'remise_id'. * @param int $socid Third party id * @param float $amount Total amount available * @param string $filter SQL filter on discounts * @param int $maxvalue Max value for lines that can be selected * @param string $more More string to add + * @param int $hidelist 1=Hide list * @return void */ - function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter='', $maxvalue=0, $more='') + function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter='', $maxvalue=0, $more='', $hidelist=0) { global $conf,$langs; if ($htmlname != "none") @@ -3929,25 +3930,30 @@ class Form print '
'; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - if (! $filter || $filter=="fk_facture_source IS NULL") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)).': '; // If we want deposit to be substracted to payments only and not to total of final invoice - else print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency)).': '; + if (! $filter || $filter=="fk_facture_source IS NULL") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)); // If we want deposit to be substracted to payments only and not to total of final invoice + else print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency)); } else { - if (! $filter || $filter=="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description LIKE '(DEPOSIT)%')") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)).': '; - else print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency)).': '; - } - print '
'; - $newfilter='fk_facture IS NULL AND fk_facture_line IS NULL'; // Remises disponibles - if ($filter) $newfilter.=' AND ('.$filter.')'; - $nbqualifiedlines=$this->select_remises($selected,$htmlname,$newfilter,$socid,$maxvalue); - if ($nbqualifiedlines > 0) - { - print '   '; + if (! $filter || $filter=="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description LIKE '(DEPOSIT)%')") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)); + else print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency)); } + if (empty($hidelist)) print ': '; print '
'; + if (empty($hidelist)) + { + print '
'; + $newfilter='fk_facture IS NULL AND fk_facture_line IS NULL'; // Remises disponibles + if ($filter) $newfilter.=' AND ('.$filter.')'; + $nbqualifiedlines=$this->select_remises($selected,$htmlname,$newfilter,$socid,$maxvalue); + if ($nbqualifiedlines > 0) + { + print '   '; + } + print '
'; + } if ($more) { print '
'; diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 6788a24baaa..881ec69190b 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -129,10 +129,10 @@ elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') ) array('varchar', 'phone', 'mail', 'select'), - 'mail'=>array('varchar', 'phone', 'mail', 'select'), - 'phone'=>array('varchar', 'phone', 'mail', 'select'), - 'select'=>array('varchar', 'phone', 'mail', 'select') + 'varchar'=>array('varchar', 'phone', 'mail', 'url', 'select'), + 'mail'=>array('varchar', 'phone', 'mail', 'url', 'select'), + 'phone'=>array('varchar', 'phone', 'mail', 'url', 'select'), + 'select'=>array('varchar', 'phone', 'mail', 'url', 'select') ); if (in_array($type, array_keys($typewecanchangeinto))) { diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index d16cd64f0ff..fdb4bf76359 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -254,7 +254,7 @@ if ($id > 0 || ! empty($ref)) // Remise dispo de type non avoir $filter='fk_facture_source IS NULL'; print '
'; - $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$commande->id,0,'remise_id',$soc->id,$absolute_discount,$filter); + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$commande->id,0,'remise_id',$soc->id,$absolute_discount,$filter, 0, '', 1); } } if ($absolute_creditnote) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 746d0ec7d77..27d86696b82 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -354,6 +354,7 @@ Boolean=Boolean (Checkbox) ExtrafieldPhone = Phone ExtrafieldPrice = Price ExtrafieldMail = Email +ExtrafieldUrl = Url ExtrafieldSelect = Select list ExtrafieldSelectList = Select from table ExtrafieldSeparator=Separator @@ -398,7 +399,7 @@ EnableAndSetupModuleCron=If you want to have this recurring invoice beeing gener ModuleCompanyCodeAquarium=Return an accountancy code built by:
%s followed by third party supplier code for a supplier accountancy code,
%s followed by third party customer code for a customer accountancy code. ModuleCompanyCodePanicum=Return an empty accountancy code. ModuleCompanyCodeDigitaria=Accountancy code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code. -Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to create and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce a third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1 validation, 2=first approval and 3=second approval if amount is enough).
Set this to empty if one approval (2 steps) is enough, set it to a very low value (0.1) if a second approval is always required. +Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to create and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce a third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1=validation, 2=first approval and 3=second approval if amount is enough).
Set this to empty if one approval (2 steps) is enough, set it to a very low value (0.1) if a second approval (3 steps) is always required. UseDoubleApproval=Use a 3 steps approval when amount (without tax) is higher than... # Modules diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php index 9f337d2eb5a..5eaa20003af 100644 --- a/htdocs/public/test/test_arrays.php +++ b/htdocs/public/test/test_arrays.php @@ -88,7 +88,6 @@ This page is a sample of page using tables. It is designed to make test with
- jmobile (add parameter ">dol_use_jmobile=4&dol_optimize_smallscreen=1 and switch to small screen < 1000 to enable view with jmobile)
- jmobile (add parameter ">dol_use_jmobile=1&dol_optimize_smallscreen=1 and switch to small screen < 570 to enable with emulated jmobile)
- no javascript / usage for bind people (add parameter ">nojs=1 to force disable javascript)
-- dataTables
- tablednd
diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php index a697b371438..a53f812611a 100644 --- a/htdocs/public/test/test_forms.php +++ b/htdocs/public/test/test_forms.php @@ -17,7 +17,8 @@ llxHeader();

This page is a sample of page using Dolibarr HTML widget methods. It is designed to make test with
- css (add parameter &theme=newtheme to test another theme or edit css of current theme)
-- jmobile (add parameter ">dol_use_jmobile=1&dol_optimize_smallscreen=1 to enable view with jmobile)
+- jmobile (add parameter ">dol_use_jmobile=4&dol_optimize_smallscreen=1 and switch to small screen < 1000 to enable view with jmobile)
+- jmobile (add parameter ">dol_use_jmobile=1&dol_optimize_smallscreen=1 and switch to small screen < 570 to enable with emulated jmobile)
- no javascript / usage for bind people (add parameter ">nojs=1 to force disable javascript)