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 (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 '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
print $form->select_date($object->date,'','','','','update');
print '</td></tr>';
// Km
print '<tr><td class="fieldrequired">'.$langs->trans("FeesKilometersOrAmout").'</td><td>';
print '<input name="km" class="flat" size="10" value="'.$object->km.'">';
print '</td></tr>';
// Where
print "<tr>";
print '<td>'.$langs->trans("CompanyVisited").'</td><td>';
print $form->select_societes($soc->id,'socid','',1);
print '</td></tr>';
// Public note
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
print '<td valign="top" colspan="3">';
print '<textarea name="note_public" cols="80" rows="8">'.$object->note_public."</textarea><br>";
print "</td></tr>";
// Private note
if (! $user->societe_id)
{
@ -311,15 +320,15 @@ else if ($id)
print '<textarea name="note_private" cols="80" rows="8">'.$object->note_private."</textarea><br>";
print "</td></tr>";
}
print '</table>';
print '<br><center><input type="submit" class="button" value="'.$langs->trans("Save").'"> &nbsp; ';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</center>';
print '</form>';
print '</div>';
}
else
@ -342,7 +351,7 @@ else if ($id)
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object,'id','',1,'rowid','ref','');
print '</td></tr>';
// Type
print '<tr><td>'.$langs->trans("Type").'</td><td>';
print $form->editInPlace($langs->trans($object->type), 'type', $user->rights->deplacement->creer, 'select', 'types_fees');
@ -356,20 +365,24 @@ else if ($id)
print '</td></tr>';
// Date
print '<tr><td>'.$langs->trans("Date").'</td><td>';
print $form->editInPlace($object->date, 'dated', $user->rights->deplacement->creer, 'datepicker');
print '<tr><td>';
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>';
// Km/Price
print '<tr><td>'.$langs->trans("FeesKilometersOrAmout").'</td>';
print '<td>'.$form->editInPlace($object->km, 'km', $user->rights->deplacement->creer, 'numeric').'</td></tr>';
// Where
print '<tr><td>'.$langs->trans("CompanyVisited").'</td>';
print '<td>';
if ($soc->id) print $soc->getNomUrl(1);
print '</td></tr>';
// Project
if ($conf->projet->enabled)
{
@ -402,13 +415,13 @@ else if ($id)
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
// Public note
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
print '<td valign="top" colspan="3">';
print $form->editInPlace($object->note_public, 'note_public', $user->rights->deplacement->creer, 'ckeditor', 'dolibarr_notes');
print "</td></tr>";
// Private note
if (! $user->societe_id)
{
@ -421,13 +434,13 @@ else if ($id)
print "</table>";
print '</div>';
/*
* Barre d'actions
*/
print '<div class="tabsAction">';
if ($user->rights->deplacement->creer)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
@ -444,7 +457,7 @@ else if ($id)
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Delete').'</a>';
}
print '</div>';
}
}

View File

@ -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;

View File

@ -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

View File

@ -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 ";

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 $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.='<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);
$ret.=$html->form_date($_SERVER['PHP_SELF'].($paramkey?'?'.$paramkey.'='.$paramvalue:''),$preselected,$htmlname);
}
$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.='</form>'."\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;
}

View File

@ -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"]);
}