NEW Can add an array of several links in date selector
This commit is contained in:
parent
017a7cb098
commit
3c0e233145
@ -169,6 +169,7 @@ NEW: Use by default the domain $dolibarr_main_url_root for SMTP HELO
|
||||
NEW: use more recent model by default
|
||||
NEW: VAT can be modified during add of line
|
||||
NEW: write all fields and their properties in asciidoc format
|
||||
NEW: Can add an array of several links in date selector
|
||||
|
||||
For developers or integrators:
|
||||
------------------------------
|
||||
|
||||
@ -38,6 +38,8 @@ require '../main.inc.php';
|
||||
|
||||
$langs->load('compta');
|
||||
|
||||
// No permission check. This is just a formatting data service.
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
|
||||
@ -6626,24 +6626,24 @@ class Form
|
||||
* - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location)
|
||||
* - Empty (fields empty), if set_time is -1 (in this case, parameter empty must also have value 1)
|
||||
*
|
||||
* @param integer|string $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2).
|
||||
* @param string $prefix Prefix for fields name
|
||||
* @param int $h 1 or 2=Show also hours (2=hours on a new line), -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show hour always empty
|
||||
* @param int $m 1=Show also minutes, -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show minutes always empty
|
||||
* @param int $empty 0=Fields required, 1=Empty inputs are allowed, 2=Empty inputs are allowed for hours only
|
||||
* @param string $form_name Not used
|
||||
* @param int $d 1=Show days, month, years
|
||||
* @param int $addnowlink Add a link "Now", 1 with server time, 2 with local computer time
|
||||
* @param int $disabled Disable input fields
|
||||
* @param int $fullday When a checkbox with id #fullday is checked, hours are set with 00:00 (if value if 'fulldaystart') or 23:59 (if value is 'fulldayend')
|
||||
* @param string $addplusone Add a link "+1 hour". Value must be name of another selectDate field.
|
||||
* @param datetime|string $adddateof Add a link "Date of ..." using the following date. See also $labeladddateof for the label used.
|
||||
* @param string $openinghours Specify hour start and hour end for the select ex 8,20
|
||||
* @param int $stepminutes Specify step for minutes between 1 and 30
|
||||
* @param string $labeladddateof Label to use for the $adddateof parameter.
|
||||
* @param string $placeholder Placeholder
|
||||
* @param mixed $gm 'auto' (for backward compatibility, avoid this), 'gmt' or 'tzserver' or 'tzuserrel'
|
||||
* @return string Html for selectDate
|
||||
* @param integer|string $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2).
|
||||
* @param string $prefix Prefix for fields name
|
||||
* @param int $h 1 or 2=Show also hours (2=hours on a new line), -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show hour always empty
|
||||
* @param int $m 1=Show also minutes, -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show minutes always empty
|
||||
* @param int $empty 0=Fields required, 1=Empty inputs are allowed, 2=Empty inputs are allowed for hours only
|
||||
* @param string $form_name Not used
|
||||
* @param int $d 1=Show days, month, years
|
||||
* @param int $addnowlink Add a link "Now", 1 with server time, 2 with local computer time
|
||||
* @param int $disabled Disable input fields
|
||||
* @param int $fullday When a checkbox with id #fullday is checked, hours are set with 00:00 (if value if 'fulldaystart') or 23:59 (if value is 'fulldayend')
|
||||
* @param string $addplusone Add a link "+1 hour". Value must be name of another selectDate field.
|
||||
* @param datetime|string|array $adddateof Add a link "Date of ..." using the following date. Must be array(array('adddateof'=>..., 'labeladddateof'=>...))
|
||||
* @param string $openinghours Specify hour start and hour end for the select ex 8,20
|
||||
* @param int $stepminutes Specify step for minutes between 1 and 30
|
||||
* @param string $labeladddateof Label to use for the $adddateof parameter. Deprecated. Used only when $adddateof is not an array.
|
||||
* @param string $placeholder Placeholder
|
||||
* @param mixed $gm 'auto' (for backward compatibility, avoid this), 'gmt' or 'tzserver' or 'tzuserrel'
|
||||
* @return string Html for selectDate
|
||||
* @see form_date(), select_month(), select_year(), select_dayofweek()
|
||||
*/
|
||||
public function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '', $openinghours = '', $stepminutes = 1, $labeladddateof = '', $placeholder = '', $gm = 'auto')
|
||||
@ -7059,17 +7059,26 @@ class Form
|
||||
}
|
||||
|
||||
// Add a link to set data
|
||||
if ($conf->use_javascript_ajax && $adddateof) {
|
||||
$tmparray = dol_getdate($adddateof);
|
||||
if (empty($labeladddateof)) {
|
||||
$labeladddateof = $langs->trans("DateInvoice");
|
||||
if ($conf->use_javascript_ajax && !empty($adddateof)) {
|
||||
if (!is_array($adddateof)) {
|
||||
$arrayofdateof = array(array('adddateof'=>$adddateof, 'labeladddateof'=>$labeladddateof));
|
||||
} else {
|
||||
$arrayofdateof = $adddateof;
|
||||
}
|
||||
foreach ($arrayofdateof as $valuedateof) {
|
||||
$tmpadddateof = $valuedateof['adddateof'];
|
||||
$tmplabeladddateof = $valuedateof['labeladddateof'];
|
||||
$tmparray = dol_getdate($tmpadddateof);
|
||||
if (empty($tmplabeladddateof)) {
|
||||
$tmplabeladddateof = $langs->trans("DateInvoice");
|
||||
}
|
||||
$reset_scripts = 'console.log(\'Click on now link\'); ';
|
||||
$reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($tmpadddateof, 'dayinputnoreduce').'\');';
|
||||
$reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.$tmparray['mday'].'\');';
|
||||
$reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.$tmparray['mon'].'\');';
|
||||
$reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.$tmparray['year'].'\');';
|
||||
$retstring .= ' - <button class="dpInvisibleButtons datenowlink" id="dateofinvoice" type="button" name="_dateofinvoice" value="now" onclick="'.$reset_scripts.'">'.$tmplabeladddateof.'</button>';
|
||||
}
|
||||
$reset_scripts = 'console.log(\'Click on now link\'); ';
|
||||
$reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($adddateof, 'dayinputnoreduce').'\');';
|
||||
$reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.$tmparray['mday'].'\');';
|
||||
$reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.$tmparray['mon'].'\');';
|
||||
$reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.$tmparray['year'].'\');';
|
||||
$retstring .= ' - <button class="dpInvisibleButtons datenowlink" id="dateofinvoice" type="button" name="_dateofinvoice" value="now" onclick="'.$reset_scripts.'">'.$labeladddateof.'</a>';
|
||||
}
|
||||
|
||||
return $retstring;
|
||||
|
||||
@ -499,8 +499,12 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
$supplierstatic->name = $obj->name;
|
||||
print $supplierstatic->getNomUrl(1, 'supplier');
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td>';
|
||||
print $form->selectDate($dateinvoice, '', '', '', 0, "addpaiement", 1, 1, 0, '', '', $object->date);
|
||||
// $object is default vendor invoice
|
||||
$adddateof = array(array('adddateof'=>$object->date));
|
||||
$adddateof[] = array('adddateof'=>$object->date_echeance, 'labeladddateof'=>$langs->transnoentities('DateDue'));
|
||||
print $form->selectDate($dateinvoice, '', '', '', 0, "addpaiement", 1, 1, 0, '', '', $adddateof);
|
||||
print '</td></tr>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('PaymentMode').'</td><td>';
|
||||
$form->select_types_paiements(!GETPOST('paiementid') ? $obj->fk_mode_reglement : GETPOST('paiementid'), 'paiementid');
|
||||
|
||||
@ -1580,6 +1580,7 @@ if ($source == 'member' || $source == 'membersubscription') {
|
||||
|
||||
if (empty($amount) && !GETPOST('newamount', 'alpha')) {
|
||||
$_GET['newamount'] = $member->last_subscription_amount;
|
||||
$_GET['amount'] = $member->last_subscription_amount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user