Qual: Revert parameter order (optionnal at end)

This commit is contained in:
Laurent Destailleur 2011-11-05 15:43:07 +01:00
parent 3f30cebce3
commit cf365593dc
6 changed files with 71 additions and 53 deletions

View File

@ -121,6 +121,7 @@ if ($action == 'add' && $user->rights->deplacement->creer)
} }
} }
// Update record
if ($action == 'update' && $user->rights->deplacement->creer) if ($action == 'update' && $user->rights->deplacement->creer)
{ {
if (empty($_POST["cancel"])) if (empty($_POST["cancel"]))
@ -162,6 +163,14 @@ if ($action == 'classin')
if ($result < 0) dol_print_error($db, $object->error); 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);
}
/* /*
@ -356,8 +365,12 @@ else if ($id)
print '</td></tr>'; print '</td></tr>';
// Date // Date
print '<tr><td>'.$langs->trans("Date").'</td><td>'; print '<tr><td>';
print $form->editInPlace($object->date, 'dated', $user->rights->deplacement->creer, 'datepicker'); 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 '</td><td colspan="3">';
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 '</td></tr>'; print '</td></tr>';
// Km/Price // Km/Price

View File

@ -223,7 +223,8 @@ if ($action == 'valid')
if ($action == 'set_thirdparty') 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); Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
exit; exit;

View File

@ -104,7 +104,7 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
if (! $error) 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 ($ret > 0)
{ {
if ($type == 'numeric') $value = price($newvalue); if ($type == 'numeric') $value = price($newvalue);

View File

@ -618,17 +618,20 @@ abstract class CommonObject
/** /**
* Update a specific field from an object * 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 string $field Field to update
* @param mixte $value New value * @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 * @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; global $conf;
if (empty($table)) $table=$this->table_element;
if (empty($id)) $id=$this->id;
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET ";

View File

@ -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 $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 string $paramvalue Value of parameter for Url
* @param boolean $perm Permission to allow button to edit parameter * @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 * @return string HTML edit field
* TODO no GET or POST in class file, use a param * 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 $text Text of label (not used in this function)
* @param string $htmlname Name of select field * @param string $htmlname Name of select field
* @param string $preselected Value to show/edit * @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 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 * @param string $editvalue Use this value instead $preselected
* @return string HTML edit field * @return string HTML edit field
* TODO no GET or POST in class file, use a param * TODO no GET or POST in class file, use a param
@ -124,20 +124,20 @@ class Form
{ {
$ret.='<textarea id="'.$htmlname.'" name="'.$htmlname.'" wrap="soft" cols="70">'.($editvalue?$editvalue:$preselected).'</textarea>'; $ret.='<textarea id="'.$htmlname.'" name="'.$htmlname.'" wrap="soft" cols="70">'.($editvalue?$editvalue:$preselected).'</textarea>';
} }
else if ($typeofdata == 'day') else if ($typeofdata == 'day' || $typeofdata == 'datepicker')
{ {
$html=new Form($db); $html=new Form($db);
$ret.=$html->form_date($_SERVER['PHP_SELF'].($paramkey?'?'.$paramkey.'='.$paramvalue:''),$preselected,$htmlname); $ret.=$html->form_date($_SERVER['PHP_SELF'].($paramkey?'?'.$paramkey.'='.$paramvalue:''),$preselected,$htmlname);
} }
$ret.='</td>'; $ret.='</td>';
if ($typeofdata != 'day') $ret.='<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; if ($typeofdata != 'day' && $typeofdata != 'datepicker') $ret.='<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
$ret.='</tr></table>'."\n"; $ret.='</tr></table>'."\n";
$ret.='</form>'."\n"; $ret.='</form>'."\n";
} }
else else
{ {
if ($typeofdata == 'email') $ret.=dol_print_email($preselected,0,0,0,0,1); 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); elseif ($typeofdata == 'text' || $typeofdata == 'textarea') $ret.=dol_htmlentitiesbr($preselected);
else $ret.=$preselected; else $ret.=$preselected;
} }

View File

@ -81,14 +81,15 @@ class InterfacePaypalWorkflow
} }
/** /**
* \brief Fonction appelee lors du declenchement d'un evenement Dolibarr. * Fonction appelee lors du declenchement d'un evenement Dolibarr.
* D'autres fonctions run_trigger peuvent etre presentes dans core/triggers * D'autres fonctions run_trigger peuvent etre presentes dans core/triggers
* \param action Code de l'evenement *
* \param object Objet concerne * @param string $action Code de l'evenement
* \param user Objet user * @param CommonObject $object Objet concerne
* \param lang Objet lang * @param User $user Objet user
* \param conf Objet conf * @param Translate $lang Objet lang
* \return int <0 if fatal error, 0 si nothing done, >0 if ok * @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) function run_trigger($action,$object,$user,$langs,$conf)
{ {
@ -123,10 +124,10 @@ class InterfacePaypalWorkflow
if ($ret < 0) return -1; if ($ret < 0) return -1;
// Add payer id // Add payer id
$soc->setValueFrom('societe', $obj->socid, 'ref_int', $object->payerID); $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
// Add transaction id // Add transaction id
$obj->setValueFrom($obj->table_element,$obj->id,'ref_int',$object->resArray["TRANSACTIONID"]); $obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]);
} }