More interactive autoselect of fields

This commit is contained in:
Laurent Destailleur 2014-03-01 19:45:13 +01:00
parent 998ecc3c15
commit d69cee03d8

View File

@ -1721,7 +1721,8 @@ jQuery(document).ready(function() {
* *
* ******************************************************************** * ********************************************************************
*/ */
if ($action == 'create') { if ($action == 'create')
{
$facturestatic = new Facture($db); $facturestatic = new Facture($db);
$extralabels = $extrafields->fetch_name_optionals_label($facturestatic->table_element); $extralabels = $extrafields->fetch_name_optionals_label($facturestatic->table_element);
@ -1791,7 +1792,7 @@ if ($action == 'create') {
$absolute_discount = $soc->getAvailableDiscounts(); $absolute_discount = $soc->getAvailableDiscounts();
if (! empty($conf->use_javascript_ajax)) { if (! empty($conf->use_javascript_ajax)) {
print ajax_combobox('fac_replacement'); //print ajax_combobox('fac_replacement');
print ajax_combobox('fac_avoir'); print ajax_combobox('fac_avoir');
} }
@ -1836,21 +1837,25 @@ if ($action == 'create') {
print '</tr>' . "\n"; print '</tr>' . "\n";
// Predefined invoices // Predefined invoices
if (empty($origin) && empty($originid) && $socid > 0) { if (empty($origin) && empty($originid) && $socid > 0)
{
$sql = 'SELECT r.rowid, r.titre, r.total_ttc'; $sql = 'SELECT r.rowid, r.titre, r.total_ttc';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_rec as r'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_rec as r';
$sql .= ' WHERE r.fk_soc = ' . $soc->id; $sql .= ' WHERE r.fk_soc = ' . $soc->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql)
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
if ($num > 0) { if ($num > 0)
{
print '<tr><td>' . $langs->trans('CreateFromRepeatableInvoice') . '</td><td>'; print '<tr><td>' . $langs->trans('CreateFromRepeatableInvoice') . '</td><td>';
print '<select class="flat" name="fac_rec">'; print '<select class="flat" name="fac_rec">';
print '<option value="0" selected="selected"></option>'; print '<option value="0" selected="selected"></option>';
while ($i < $num) { while ($i < $num)
{
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
print '<option value="' . $objp->rowid . '"'; print '<option value="' . $objp->rowid . '"';
if (GETPOST('fac_rec') == $objp->rowid) if (GETPOST('fac_rec') == $objp->rowid)
@ -1873,7 +1878,8 @@ if ($action == 'create') {
exit(); exit();
} }
$options = ""; $options = "";
foreach ($facids as $facparam) { foreach ($facids as $facparam)
{
$options .= '<option value="' . $facparam ['id'] . '"'; $options .= '<option value="' . $facparam ['id'] . '"';
if ($facparam ['id'] == $_POST ['fac_replacement']) if ($facparam ['id'] == $_POST ['fac_replacement'])
$options .= ' selected="selected"'; $options .= ' selected="selected"';
@ -1889,7 +1895,8 @@ if ($action == 'create') {
} }
$optionsav = ""; $optionsav = "";
$newinvoice_static = new Facture($db); $newinvoice_static = new Facture($db);
foreach ($facids as $key => $valarray) { foreach ($facids as $key => $valarray)
{
$newinvoice_static->id = $key; $newinvoice_static->id = $key;
$newinvoice_static->ref = $valarray ['ref']; $newinvoice_static->ref = $valarray ['ref'];
$newinvoice_static->statut = $valarray ['status']; $newinvoice_static->statut = $valarray ['status'];
@ -1917,7 +1924,8 @@ if ($action == 'create') {
print '</td></tr>' . "\n"; print '</td></tr>' . "\n";
// Proforma // Proforma
if (! empty($conf->global->FACTURE_USE_PROFORMAT)) { if (! empty($conf->global->FACTURE_USE_PROFORMAT))
{
print '<tr height="18"><td width="16px" valign="middle">'; print '<tr height="18"><td width="16px" valign="middle">';
print '<input type="radio" name="type" value="4"' . (GETPOST('type') == 4 ? ' checked="checked"' : '') . '>'; print '<input type="radio" name="type" value="4"' . (GETPOST('type') == 4 ? ' checked="checked"' : '') . '>';
print '</td><td valign="middle">'; print '</td><td valign="middle">';
@ -1926,11 +1934,19 @@ if ($action == 'create') {
print '</td></tr>' . "\n"; print '</td></tr>' . "\n";
} }
if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid)))) { if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid))))
{
// Deposit // Deposit
print '<tr height="18"><td width="16px" valign="middle">'; print '<tr height="18"><td width="16px" valign="middle">';
print '<input type="radio" name="type" value="3"' . (GETPOST('type') == 3 ? ' checked="checked"' : '') . '>'; print '<input type="radio" id="radio_deposit" name="type" value="3"' . (GETPOST('type') == 3 ? ' checked="checked"' : '') . '>';
print '</td><td valign="middle" class="nowrap">'; print '</td><td valign="middle" class="nowrap">';
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#typedeposit, #valuedeposit").click(function() {
jQuery("#radio_deposit").attr(\'checked\',\'checked\');
});
});
</script>';
$desc = $form->textwithpicto($langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1); $desc = $form->textwithpicto($langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1);
print '<table class="nobordernopadding"><tr><td>' . $desc . '</td>'; print '<table class="nobordernopadding"><tr><td>' . $desc . '</td>';
if (($origin == 'propal') || ($origin == 'commande')) { if (($origin == 'propal') || ($origin == 'commande')) {
@ -1938,27 +1954,35 @@ if ($action == 'create') {
$arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount');
print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1); print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1);
print '</td>'; print '</td>';
print '<td class="nowrap" style="padding-left: 5px">' . $langs->trans('Value') . ':<input type="text" name="valuedeposit" size="3" value="' . GETPOST('valuedeposit', 'int') . '"/>'; print '<td class="nowrap" style="padding-left: 5px">' . $langs->trans('Value') . ':<input type="text" id="valuedeposit" name="valuedeposit" size="3" value="' . GETPOST('valuedeposit', 'int') . '"/>';
} }
print '</td></tr></table>'; print '</td></tr></table>';
print '</td></tr>' . "\n"; print '</td></tr>' . "\n";
} }
if ($socid > 0) { if ($socid > 0)
{
// Replacement // Replacement
print '<tr height="18"><td valign="middle">'; print '<tr height="18"><td valign="middle">';
print '<input type="radio" name="type" value="1"' . (GETPOST('type') == 1 ? ' checked="checked"' : ''); print '<input type="radio" name="type" id="radio_replacement" value="1"' . (GETPOST('type') == 1 ? ' checked="checked"' : '');
if (! $options) if (! $options)
print ' disabled="disabled"'; print ' disabled="disabled"';
print '>'; print '>';
print '</td><td valign="middle">'; print '</td><td valign="middle">';
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#fac_replacement").change(function() {
jQuery("#radio_replacement").attr(\'checked\',\'checked\');
});
});
</script>';
$text = $langs->trans("InvoiceReplacementAsk") . ' '; $text = $langs->trans("InvoiceReplacementAsk") . ' ';
$text .= '<select class="flat" name="fac_replacement" id="fac_replacement"'; $text .= '<select class="flat" name="fac_replacement" id="fac_replacement"';
if (! $options) if (! $options)
$text .= ' disabled="disabled"'; $text .= ' disabled="disabled"';
$text .= '>'; $text .= '>';
if ($options) { if ($options) {
$text .= '<option value="-1"></option>'; $text .= '<option value="-1">&nbsp;</option>';
$text .= $options; $text .= $options;
} else { } else {
$text .= '<option value="-1">' . $langs->trans("NoReplacableInvoice") . '</option>'; $text .= '<option value="-1">' . $langs->trans("NoReplacableInvoice") . '</option>';
@ -1969,7 +1993,8 @@ if ($action == 'create') {
print '</td></tr>' . "\n"; print '</td></tr>' . "\n";
} }
if (empty($origin) && $socid > 0) { if (empty($origin) && $socid > 0)
{
// Credit note // Credit note
print '<tr height="18"><td valign="middle">'; print '<tr height="18"><td valign="middle">';
print '<input type="radio" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked=true' : ''); print '<input type="radio" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked=true' : '');