From cf365593dc2ff41a163a76fa896de4dd25954545 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Nov 2011 15:43:07 +0100 Subject: [PATCH] Qual: Revert parameter order (optionnal at end) --- htdocs/compta/deplacement/fiche.php | 53 ++++++++++++------- htdocs/compta/facture.php | 3 +- htdocs/core/ajax/saveinplace.php | 24 ++++----- htdocs/core/class/commonobject.class.php | 11 ++-- htdocs/core/class/html.form.class.php | 12 ++--- ...terface_modPaypal_PaypalWorkflow.class.php | 21 ++++---- 6 files changed, 71 insertions(+), 53 deletions(-) diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index 03e7c165847..7e38119641b 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -121,6 +121,7 @@ if ($action == 'add' && $user->rights->deplacement->creer) } } +// Update record if ($action == 'update' && $user->rights->deplacement->creer) { if (empty($_POST["cancel"])) @@ -134,7 +135,7 @@ if ($action == 'update' && $user->rights->deplacement->creer) $object->socid = $_POST["socid"]; $object->note_private = $_POST["note_private"]; $object->note_public = $_POST["note_public"]; - + $result = $object->update($user); if ($result > 0) @@ -162,6 +163,14 @@ if ($action == 'classin') if ($result < 0) dol_print_error($db, $object->error); } +// Set fields +if ($action == 'setdated') +{ + $dated=dol_mktime($_POST['datedhour'], $_POST['datedmin'], $_POST['datedsec'], $_POST['datedmonth'], $_POST['datedday'], $_POST['datedyear']); + $object->fetch($id); + $result=$object->setValueFrom('dated',$dated,'','','date'); + if ($result < 0) dol_print_error($db, $object->error); +} /* @@ -285,24 +294,24 @@ else if ($id) print ''.$langs->trans("Date").''; print $form->select_date($object->date,'','','','','update'); print ''; - + // Km print ''.$langs->trans("FeesKilometersOrAmout").''; print ''; print ''; - + // Where print ""; print ''.$langs->trans("CompanyVisited").''; print $form->select_societes($soc->id,'socid','',1); print ''; - + // Public note print ''.$langs->trans("NotePublic").''; print ''; print '
"; print ""; - + // Private note if (! $user->societe_id) { @@ -311,15 +320,15 @@ else if ($id) print '
"; print ""; } - + print ''; - + print '
  '; print ''; print '
'; - + print ''; - + print ''; } else @@ -342,7 +351,7 @@ else if ($id) print ''.$langs->trans("Ref").''; print $form->showrefnav($object,'id','',1,'rowid','ref',''); print ''; - + // Type print ''.$langs->trans("Type").''; print $form->editInPlace($langs->trans($object->type), 'type', $user->rights->deplacement->creer, 'select', 'types_fees'); @@ -356,20 +365,24 @@ else if ($id) print ''; // Date - print ''.$langs->trans("Date").''; - print $form->editInPlace($object->date, 'dated', $user->rights->deplacement->creer, 'datepicker'); + print ''; + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) print $langs->trans('Date'); + else print $form->editfieldkey("Date",'dated',$object->date,'id',$object->id,$user->rights->deplacement->creer,'datepicker'); + print ''; + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) print $form->editInPlace($object->date, 'dated', $user->rights->deplacement->creer, 'datepicker'); + else print $form->editfieldval("Date",'dated',$object->date,'id',$object->id,$user->rights->deplacement->creer,'datepicker'); print ''; // Km/Price print ''.$langs->trans("FeesKilometersOrAmout").''; print ''.$form->editInPlace($object->km, 'km', $user->rights->deplacement->creer, 'numeric').''; - + // Where print ''.$langs->trans("CompanyVisited").''; print ''; if ($soc->id) print $soc->getNomUrl(1); print ''; - + // Project if ($conf->projet->enabled) { @@ -402,13 +415,13 @@ else if ($id) // Statut print ''.$langs->trans("Status").''.$object->getLibStatut(4).''; - + // Public note print ''.$langs->trans("NotePublic").''; print ''; print $form->editInPlace($object->note_public, 'note_public', $user->rights->deplacement->creer, 'ckeditor', 'dolibarr_notes'); print ""; - + // Private note if (! $user->societe_id) { @@ -421,13 +434,13 @@ else if ($id) print ""; print ''; - + /* * Barre d'actions */ - + print '
'; - + if ($user->rights->deplacement->creer) { print ''.$langs->trans('Modify').''; @@ -444,7 +457,7 @@ else if ($id) { print ''.$langs->trans('Delete').''; } - + print '
'; } } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 21c4e24caa8..25cd3a251f5 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -223,7 +223,8 @@ if ($action == 'valid') if ($action == 'set_thirdparty') { - $object->setValueFrom('facture',$id,'fk_soc',$socid); + $object->fetch($id); + $object->setValueFrom('fk_soc',$socid); Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit; diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 3f4c3d07560..954067d37ee 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -51,30 +51,30 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) $fk_element = GETPOST('fk_element'); $value = GETPOST('value'); $type = GETPOST('type'); - + $format='text'; $return=array(); $error=0; - + if (preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) { $element = $regs[1]; $subelement = $regs[2]; } - + if ($element == 'fichinter') $element = 'ficheinter'; - + if ($user->rights->$element->creer || $user->rights->$element->write) { $object = new GenericObject($db); - + // Clean parameters $newvalue = trim($value); - + if ($type == 'numeric') { $newvalue = price2num($newvalue); - + // Check parameters if (! is_numeric($newvalue)) { @@ -92,7 +92,7 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) { $methodname = 'load_cache_'.GETPOST('method'); $cachename = 'cache_'.GETPOST('method'); - + $form = new Form($db); $ret = $form->$methodname(); if ($ret > 0) @@ -101,15 +101,15 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) $value = $cache[$newvalue]; } } - + if (! $error) { - $ret=$object->setValueFrom($table_element, $fk_element, $field, $newvalue, $format); + $ret=$object->setValueFrom($field, $newvalue, $table_element, $fk_element, $format); if ($ret > 0) { if ($type == 'numeric') $value = price($newvalue); else if ($type == 'textarea') $value = dol_nl2br($newvalue); - + $return['value'] = $value; } else @@ -117,7 +117,7 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) $return['error'] = $object->error; } } - + echo json_encode($return); } else diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 22f5a1ae705..17a18a006fa 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -618,17 +618,20 @@ abstract class CommonObject /** * Update a specific field from an object * - * @param string $table Table element or element line - * @param int $id Object id * @param string $field Field to update * @param mixte $value New value - * @param string $format Data format + * @param string $table To force other table element or element line + * @param int $id To force other object id + * @param string $format Data format ('text' by default, 'date') * @return int <0 if KO, >0 if OK */ - function setValueFrom($table, $id, $field, $value, $format='text') + function setValueFrom($field, $value, $table='', $id='', $format='text') { global $conf; + if (empty($table)) $table=$this->table_element; + if (empty($id)) $id=$this->id; + $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1d7f3a89009..08c5afd4b85 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -74,7 +74,7 @@ class Form * @param string $paramkey Key of parameter for Url (unique if there is several parameter to show). In most cases "id". * @param string $paramvalue Value of parameter for Url * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'text' or 'textarea', 'day', ...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'text' or 'textarea', 'day' or 'datepicker', ...) * @return string HTML edit field * TODO no GET or POST in class file, use a param */ @@ -96,9 +96,9 @@ class Form * @param string $text Text of label (not used in this function) * @param string $htmlname Name of select field * @param string $preselected Value to show/edit - * @param string $paramkey Key of parameter (unique if there is several parameter to show) + * @param string $paramkey Key of parameter (unique if there is several parameter to show). In most cases "id". * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'text' or 'textarea', 'day', ...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'text' or 'textarea', 'day' or 'datepicker', ...) * @param string $editvalue Use this value instead $preselected * @return string HTML edit field * TODO no GET or POST in class file, use a param @@ -124,20 +124,20 @@ class Form { $ret.=''; } - else if ($typeofdata == 'day') + else if ($typeofdata == 'day' || $typeofdata == 'datepicker') { $html=new Form($db); $ret.=$html->form_date($_SERVER['PHP_SELF'].($paramkey?'?'.$paramkey.'='.$paramvalue:''),$preselected,$htmlname); } $ret.=''; - if ($typeofdata != 'day') $ret.=''; + if ($typeofdata != 'day' && $typeofdata != 'datepicker') $ret.=''; $ret.=''."\n"; $ret.=''."\n"; } else { if ($typeofdata == 'email') $ret.=dol_print_email($preselected,0,0,0,0,1); - elseif ($typeofdata == 'day') $ret.=dol_print_date($preselected,'day'); + elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret.=dol_print_date($preselected,'day'); elseif ($typeofdata == 'text' || $typeofdata == 'textarea') $ret.=dol_htmlentitiesbr($preselected); else $ret.=$preselected; } diff --git a/htdocs/core/triggers/interface_modPaypal_PaypalWorkflow.class.php b/htdocs/core/triggers/interface_modPaypal_PaypalWorkflow.class.php index 370d47305b3..c44554ba466 100644 --- a/htdocs/core/triggers/interface_modPaypal_PaypalWorkflow.class.php +++ b/htdocs/core/triggers/interface_modPaypal_PaypalWorkflow.class.php @@ -81,14 +81,15 @@ class InterfacePaypalWorkflow } /** - * \brief Fonction appelee lors du declenchement d'un evenement Dolibarr. - * D'autres fonctions run_trigger peuvent etre presentes dans core/triggers - * \param action Code de l'evenement - * \param object Objet concerne - * \param user Objet user - * \param lang Objet lang - * \param conf Objet conf - * \return int <0 if fatal error, 0 si nothing done, >0 if ok + * Fonction appelee lors du declenchement d'un evenement Dolibarr. + * D'autres fonctions run_trigger peuvent etre presentes dans core/triggers + * + * @param string $action Code de l'evenement + * @param CommonObject $object Objet concerne + * @param User $user Objet user + * @param Translate $lang Objet lang + * @param Conf $conf Objet conf + * @return int <0 if fatal error, 0 si nothing done, >0 if ok */ function run_trigger($action,$object,$user,$langs,$conf) { @@ -123,10 +124,10 @@ class InterfacePaypalWorkflow if ($ret < 0) return -1; // Add payer id - $soc->setValueFrom('societe', $obj->socid, 'ref_int', $object->payerID); + $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid); // Add transaction id - $obj->setValueFrom($obj->table_element,$obj->id,'ref_int',$object->resArray["TRANSACTIONID"]); + $obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]); }