From 3cdff5361fcf7009bc29c8a879dd2440be8a9197 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Mar 2012 12:18:23 +0100 Subject: [PATCH 01/10] Fix: add empty message in combobox --- htdocs/core/class/html.form.class.php | 8 ++++++-- htdocs/core/tpl/contacts.tpl.php | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 03d5ddb35de..e518fab260d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -815,9 +815,9 @@ class Form if ($resql) { $num=$this->db->num_rows($resql); - if ($num == 0) return 0; + $disable=($num==0 ? ' disabled="disabled"' : ''); - if ($htmlname != 'none') print ''; if ($showempty) print ''; $num = $this->db->num_rows($resql); $i = 0; @@ -870,6 +870,10 @@ class Form $i++; } } + else + { + print ''; + } if ($htmlname != 'none') { print ''; diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 3143722e952..800ed417988 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -76,7 +76,6 @@ $userstatic=new User($db); select_contacts($selectedCompany, '', 'contactid'); ?> - trans("NoContactDefined"); ?> selectTypeContact($object, '', 'type','external'); ?> From 808c4b573221da7e9df59a404cd87ddb0ba60980 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Mar 2012 14:06:55 +0100 Subject: [PATCH 02/10] New: testing a new method to avoid reloading the page --- htdocs/comm/propal.php | 5 +- htdocs/comm/propal/contact.php | 11 ++-- htdocs/commande/contact.php | 3 +- htdocs/commande/fiche.php | 5 +- htdocs/compta/facture.php | 5 +- htdocs/compta/facture/contact.php | 3 +- htdocs/contrat/contact.php | 3 +- htdocs/contrat/fiche.php | 5 +- htdocs/core/ajax/contacts.php | 58 ++++++++++++++++++ htdocs/core/class/html.form.class.php | 88 +++++++++++++++++---------- htdocs/core/lib/ajax.lib.php | 14 ++++- htdocs/core/tpl/contacts.tpl.php | 16 +++-- htdocs/fourn/commande/contact.php | 3 +- htdocs/fourn/commande/fiche.php | 5 +- htdocs/fourn/facture/contact.php | 3 +- htdocs/fourn/facture/fiche.php | 5 +- 16 files changed, 171 insertions(+), 61 deletions(-) create mode 100644 htdocs/core/ajax/contacts.php diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 431190327da..79fcafbad3a 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1051,8 +1051,9 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) $result = $object->fetch($id); if ($result > 0 && $id > 0) - { - $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index b7c0e83904c..46ce0ac7afe 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -35,10 +35,10 @@ $langs->load("orders"); $langs->load("sendings"); $langs->load("companies"); -$id=GETPOST('id', 'int'); -$ref= GETPOST('ref', 'alpha'); -$lineid=GETPOST('lineid', 'int'); -$action=GETPOST('action', 'alpha'); +$id=GETPOST('id','int'); +$ref= GETPOST('ref','alpha'); +$lineid=GETPOST('lineid','int'); +$action=GETPOST('action','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; @@ -57,7 +57,8 @@ if ($action == 'addcontact' && $user->rights->propale->creer) if ($result > 0 && $id > 0) { - $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index eeca19cce3c..9e4cfd2923b 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -54,7 +54,8 @@ if ($action == 'addcontact' && $user->rights->commande->creer) if ($result > 0 && $id > 0) { - $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 976b62d9fb4..ec39a9b14c8 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1198,8 +1198,9 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) $result = $object->fetch($id); if ($result > 0 && $id > 0) - { - $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 439062a6517..6a280ba068a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1513,8 +1513,9 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) $result = $object->fetch($id); if ($result > 0 && $id > 0) - { - $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 59b61483541..d840db56dce 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -55,7 +55,8 @@ if ($action == 'addcontact' && $user->rights->facture->creer) if ($result > 0 && $id > 0) { - $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 8482df92fcc..7a35a414481 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -56,7 +56,8 @@ if ($action == 'addcontact' && $user->rights->contrat->creer) if ($result > 0 && $id > 0) { - $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 2da8fc9083d..3cacf53ee17 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -483,8 +483,9 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) $result = $object->fetch($id); if ($result > 0 && $id > 0) - { - $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) diff --git a/htdocs/core/ajax/contacts.php b/htdocs/core/ajax/contacts.php new file mode 100644 index 00000000000..025d1dc9dd0 --- /dev/null +++ b/htdocs/core/ajax/contacts.php @@ -0,0 +1,58 @@ + + * + * 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 2 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/core/ajax/contacts.php + * \brief File to load contacts combobox + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); + +require('../../main.inc.php'); + +$id = GETPOST('id','int'); +$action = GETPOST('action','alpha'); +$htmlname = GETPOST('htmlname','alpha'); + +/* + * View + */ + +top_httphead(); + +//print ''."\n"; + +// Load original field value +if (! empty($id) && ! empty($action) && ! empty($htmlname)) +{ + $form = new Form($db); + + $return=array(); + + $return['value'] = $form->selectcontacts($id,'','contactid',0,'','',0,'',true); + $return['num'] = $form->num; + $return['error'] = $form->error; + + echo json_encode($return); +} + +?> diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e518fab260d..b380b384713 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -42,6 +42,7 @@ class Form { var $db; var $error; + var $num; // Cache arrays var $cache_types_paiements=array(); @@ -785,23 +786,45 @@ class Form } } + /** + * Return list of all contacts (for a third party or all) + * + * @param int $socid Id ot third party or 0 for all + * @param string $selected Id contact pre-selectionne + * @param string $htmlname Name of HTML field ('none' for a not editable field) + * @param int $show_empty 0=no empty value, 1=add an empty value + * @param string $exclude List of contacts id to exclude + * @param string $limitto Disable answers that are not id in this array list + * @param string $showfunction Add function into label + * @param string $moreclass Add more class to class style + * @return int <0 if KO, Nb of contact in list if OK + */ + function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='') + { + print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass); + } /** - * Return list of all contacts (for a third party or all) + * Return list of all contacts (for a third party or all) * - * @param int $socid Id ot third party or 0 for all - * @param string $selected Id contact pre-selectionne - * @param string $htmlname Name of HTML field ('none' for a not editable field) - * @param int $show_empty 0=no empty value, 1=add an empty value - * @param string $exclude List of contacts id to exclude - * @param string $limitto Disable answers that are not id in this array list - * @param string $showfunction Add function into label - * @param string $moreclass Add more class to class style - * @return int <0 if KO, Nb of contact in list if OK + * @param int $socid Id ot third party or 0 for all + * @param string $selected Id contact pre-selectionne + * @param string $htmlname Name of HTML field ('none' for a not editable field) + * @param int $show_empty 0=no empty value, 1=add an empty value + * @param string $exclude List of contacts id to exclude + * @param string $limitto Disable answers that are not id in this array list + * @param string $showfunction Add function into label + * @param string $moreclass Add more class to class style + * @param bool $options_only Return options only (for ajax treatment) + * @return int <0 if KO, Nb of contact in list if OK */ - function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='') + function selectcontacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $options_only=false) { global $conf,$langs; + + $langs->load('companies'); + + $out=''; // On recherche les societes $sql = "SELECT sp.rowid, sp.name as name, sp.firstname, sp.poste"; @@ -815,10 +838,9 @@ class Form if ($resql) { $num=$this->db->num_rows($resql); - $disable=($num==0 ? ' disabled="disabled"' : ''); - if ($htmlname != 'none') print ''; + if ($showempty) $out.= ''; $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -842,29 +864,29 @@ class Form if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1; if ($selected && $selected == $obj->rowid) { - print ''; + $out.= ''; } else { - print ''; + $out.= ''; } } else { if ($selected == $obj->rowid) { - print $contactstatic->getFullName($langs); - if ($showfunction && $obj->poste) print ' ('.$obj->poste.')'; + $out.= $contactstatic->getFullName($langs); + if ($showfunction && $obj->poste) $out.= ' ('.$obj->poste.')'; } } $i++; @@ -872,13 +894,15 @@ class Form } else { - print ''; + $out.= ''; } - if ($htmlname != 'none') + if ($htmlname != 'none' || $options_only) { - print ''; + $out.= ''; } - return $num; + + $this->num = $num; + return $out; } else { diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 2d7426f279e..f433374f83c 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -225,14 +225,24 @@ function ajax_combobox($htmlname, $event=array()) var method = obj.method; var url = obj.url; var htmlname = obj.htmlname; - $.get(url, + $.getJSON(url, { action: method, id: id, htmlname: htmlname }, function(response) { - $("select#" + htmlname).html(response); + $.each(obj.params, function(key,action) { + if (key.length) { + var num = response.num; + if (num > 0) { + $("#" + key).removeAttr(action); + } else { + $("#" + key).attr(action, action); + } + } + }); + $("select#" + htmlname).html(response.value); }); } });'; diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 800ed417988..b1e685104ab 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -54,7 +54,7 @@ $userstatic=new User($db); > trans("Users"); ?> global->MAIN_INFO_SOCIETE_NOM; ?> - select_users($user->id,'contactid',0,$userAlreadySelected); ?> + select_users($user->id,'userid',0,$userAlreadySelected); ?> selectTypeContact($object, '', 'type','internal'); ?> "> @@ -71,17 +71,23 @@ $userstatic=new User($db); > trans("ThirdPartyContacts"); ?> - socid; ?> - selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany'); ?> + socid; ?> + selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany'); ?> + 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); + print $form->select_company($object->socid,'socid','',1,0,0,$events); + ?> - select_contacts($selectedCompany, '', 'contactid'); ?> + select_contacts($selectedCompany, '', 'contactid'); ?> + select_contacts($object->socid, '', 'contactid'); ?> selectTypeContact($object, '', 'type','external'); ?> - "> + "> diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index efb490a8261..be532b75261 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -55,7 +55,8 @@ if ($action == 'addcontact' && $user->rights->fournisseur->commande->creer) if ($result > 0 && $id > 0) { - $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index bc60fcc1217..18297d7ae0f 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -819,8 +819,9 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) $result = $object->fetch($id); if ($result > 0 && $id > 0) - { - $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index 3a863c1d5c5..1a4e97e34f4 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -55,7 +55,8 @@ if ($action == 'addcontact' && $user->rights->fournisseur->facture->creer) if ($result > 0 && $id > 0) { - $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index b11ac83c102..b09a5107500 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -838,8 +838,9 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) $result = $object->fetch($id); if ($result > 0 && $id > 0) - { - $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) From 7f7ef8da1e36e4c42eadeb4cf1fefad91c5c5863 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Mar 2012 14:10:04 +0100 Subject: [PATCH 03/10] Fix: this parameter is used by editInPlace() method for define the save method --- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/tpl/notes.tpl.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index aabd0eb636a..d6500658dd1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -75,7 +75,7 @@ class Form * @param string $preselected Name of Value to show/edit (not used in this function) * @param object $object Object * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:?:1:rows:cols', 'select:xxx'...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select:xxx'...) * @param string $moreparam More param to add on a href URL * @return string HTML edit field */ @@ -120,7 +120,7 @@ class Form * @param string $value Value to show/edit * @param object $object Object * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:?:1:rows:cols', 'select:xxx'...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select:xxx'...) * @param string $editvalue When in edit mode, use this value as $value instead of value * @param object $extObject External object * @param string $success Success message diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index f2b6c581af4..a5f17c5696e 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -32,7 +32,7 @@ elseif ($module == 'project_task') { $note_private = 'note_private'; } elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; } elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; } -if (! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200:?:1:12:100'; +if (! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:100'; else $typeofdata='textarea:12:100'; ?> From 5d33f687aebae2b281dabbed8ba2c68742ccd86e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Mar 2012 14:17:10 +0100 Subject: [PATCH 04/10] Fix: change for getJSON format --- htdocs/core/ajax/vatrates.php | 8 +++++++- htdocs/core/class/html.form.class.php | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/ajax/vatrates.php b/htdocs/core/ajax/vatrates.php index d987b074bc6..c4ecc36ae9b 100644 --- a/htdocs/core/ajax/vatrates.php +++ b/htdocs/core/ajax/vatrates.php @@ -49,7 +49,13 @@ if (! empty($id) && ! empty($action) && ! empty($htmlname)) $soc->fetch($id); - echo $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true); + $return=array(); + + $return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true); + $return['num'] = $form->num; + $return['error'] = $form->error; + + echo json_encode($return); } ?> diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d6500658dd1..6a231f95f33 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3047,7 +3047,8 @@ class Form { $return.= $this->error; } - + + $this->num = $num; return $return; } From 79bdb85f6db7494331e42658bc526888bade9ea0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Mar 2012 14:25:39 +0100 Subject: [PATCH 05/10] Fix: missing return num --- htdocs/core/class/html.form.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6a231f95f33..08787c8b1bc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -802,6 +802,7 @@ class Form function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='') { print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass); + return $this->num; } /** From 370979f6c657dca5182c02c013448cf8d2b5307d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Mar 2012 14:40:42 +0100 Subject: [PATCH 06/10] Fix: for compatibility --- htdocs/core/tpl/contacts.tpl.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index b1e685104ab..5c4368d4bc0 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -70,9 +70,8 @@ $userstatic=new User($db); > trans("ThirdPartyContacts"); ?> + use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) { ?> - socid; ?> - selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany'); ?> 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); @@ -80,9 +79,17 @@ $userstatic=new User($db); ?> - select_contacts($selectedCompany, '', 'contactid'); ?> select_contacts($object->socid, '', 'contactid'); ?> + + + socid; ?> + selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany'); ?> + + + select_contacts($selectedCompany, '', 'contactid'); ?> + + selectTypeContact($object, '', 'type','external'); ?> From 05a5a0fc9ae87848b4666b5c146957cb0695febe Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Mar 2012 15:15:11 +0100 Subject: [PATCH 07/10] Fix: bypass GETPOST check with ckeditor --- htdocs/core/ajax/saveinplace.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index bdedcd6b2db..ad52fd846a6 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -49,8 +49,8 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($ { $ext_element = GETPOST('ext_element','alpha'); $field = substr($field, 8); // remove prefix val_ - $value = GETPOST('value','alpha'); $type = GETPOST('type','alpha'); + $value = ($type == 'ckeditor' ? GETPOST('value') : GETPOST('value','alpha')); $savemethod = GETPOST('savemethod','alpha'); $savemethodname = (! empty($savemethod) ? $savemethod : 'setValueFrom'); From f66236af810d40e5ef4c34db3650a987c3ea2c65 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Mar 2012 15:20:25 +0100 Subject: [PATCH 08/10] Fix: check only POST --- htdocs/core/ajax/saveinplace.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index ad52fd846a6..300c36124ac 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -30,10 +30,10 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); require('../../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php"); -$field = GETPOST('field','alpha'); -$element = GETPOST('element','alpha'); -$table_element = GETPOST('table_element','alpha'); -$fk_element = GETPOST('fk_element','alpha'); +$field = GETPOST('field','alpha',2); +$element = GETPOST('element','alpha',2); +$table_element = GETPOST('table_element','alpha',2); +$fk_element = GETPOST('fk_element','alpha',2); /* * View @@ -47,11 +47,11 @@ top_httphead(); // Load original field value if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($fk_element)) { - $ext_element = GETPOST('ext_element','alpha'); + $ext_element = GETPOST('ext_element','alpha',2); $field = substr($field, 8); // remove prefix val_ - $type = GETPOST('type','alpha'); - $value = ($type == 'ckeditor' ? GETPOST('value') : GETPOST('value','alpha')); - $savemethod = GETPOST('savemethod','alpha'); + $type = GETPOST('type','alpha',2); + $value = ($type == 'ckeditor' ? GETPOST('value',2) : GETPOST('value','alpha',2)); + $savemethod = GETPOST('savemethod','alpha',2); $savemethodname = (! empty($savemethod) ? $savemethod : 'setValueFrom'); $view=''; @@ -98,7 +98,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($ } else if ($type == 'datepicker') { - $timestamp = GETPOST('timestamp','int'); + $timestamp = GETPOST('timestamp','int',2); $format = 'date'; $newvalue = ($timestamp / 1000); } From b82ff3f75991edb7d7599156aeec85c2c03c5102 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Mar 2012 15:22:15 +0100 Subject: [PATCH 09/10] Fix: missing parameter --- htdocs/core/ajax/saveinplace.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 300c36124ac..9af6a83e54a 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -50,7 +50,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($ $ext_element = GETPOST('ext_element','alpha',2); $field = substr($field, 8); // remove prefix val_ $type = GETPOST('type','alpha',2); - $value = ($type == 'ckeditor' ? GETPOST('value',2) : GETPOST('value','alpha',2)); + $value = ($type == 'ckeditor' ? GETPOST('value','',2) : GETPOST('value','alpha',2)); $savemethod = GETPOST('savemethod','alpha',2); $savemethodname = (! empty($savemethod) ? $savemethod : 'setValueFrom'); From 579df2b131f03613f6f412b354e06a520845be5b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Mar 2012 15:30:01 +0100 Subject: [PATCH 10/10] Add TODO --- htdocs/core/class/html.formcompany.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 6e1e06f6279..52c0ce52e5f 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -509,6 +509,9 @@ class FormCompany * @param string $limitto Disable answers that are not id in this array list * @param int $forceid This is to force antoher object id than object->id * @return void + * TODO obsolete ? + * cette fonction doit utiliser du javascript quoi qu'il en soit ! + * autant utiliser le système combobox sans rechargement de page non ? */ function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0) {