No more need to set scroolTop, lines are sorted with last added first

This commit is contained in:
Laurent Destailleur 2019-03-27 20:20:39 +01:00
parent ff10a2ab5a
commit 9105e205ff
4 changed files with 49 additions and 41 deletions

View File

@ -61,7 +61,7 @@ if ($action=="change") {
?> ?>
<script> <script>
parent.$("#poslines").load("invoice.php?place="+<?php print $place;?>, function() { parent.$("#poslines").load("invoice.php?place="+<?php print $place;?>, function() {
parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight); //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
parent.$.colorbox.close(); parent.$.colorbox.close();
}); });
</script> </script>

View File

@ -407,39 +407,47 @@ print "</tr>\n";
if ($placeid > 0) if ($placeid > 0)
{ {
$tmplines = array_reverse($invoice->lines); if (is_array($invoice->lines) && count($invoice->lines))
foreach($tmplines as $line)
{ {
$htmlforlines = ''; $tmplines = array_reverse($invoice->lines);
foreach($tmplines as $line)
$htmlforlines.= '<tr class="drag drop oddeven';
if ($line->special_code == "3") {
$htmlforlines.= ' order';
}
$htmlforlines.= '" id="' . $line->id . '">';
$htmlforlines.= '<td class="left">';
$htmlforlines.= $line->product_label;
if ($line->product_label && $line->desc) $htmlforlines.= '<br>';
if ($line->product_label != $line->desc)
{ {
$firstline = dolGetFirstLineOfText($line->desc); $htmlforlines = '';
if ($firstline != $line->desc)
{ $htmlforlines.= '<tr class="drag drop oddeven';
$htmlforlines.= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); if ($line->special_code == "3") {
} $htmlforlines.= ' order';
else }
{ $htmlforlines.= '" id="' . $line->id . '">';
$htmlforlines.= $line->desc; $htmlforlines.= '<td class="left">';
} $htmlforlines.= $line->product_label;
} if ($line->product_label && $line->desc) $htmlforlines.= '<br>';
if (!empty($line->array_options['options_order_notes'])) $htmlforlines.= "<br>(".$line->array_options['options_order_notes'].")"; if ($line->product_label != $line->desc)
$htmlforlines.= '</td>'; {
$htmlforlines.= '<td class="right">' . vatrate($line->remise_percent, true) . '</td>'; $firstline = dolGetFirstLineOfText($line->desc);
$htmlforlines.= '<td class="right">' . $line->qty . '</td>'; if ($firstline != $line->desc)
$htmlforlines.= '<td class="right">' . price($line->total_ttc) . '</td>'; {
$htmlforlines.= '</tr>'."\n"; $htmlforlines.= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
}
else
{
$htmlforlines.= $line->desc;
}
}
if (!empty($line->array_options['options_order_notes'])) $htmlforlines.= "<br>(".$line->array_options['options_order_notes'].")";
$htmlforlines.= '</td>';
$htmlforlines.= '<td class="right">' . vatrate($line->remise_percent, true) . '</td>';
$htmlforlines.= '<td class="right">' . $line->qty . '</td>';
$htmlforlines.= '<td class="right">' . price($line->total_ttc) . '</td>';
$htmlforlines.= '</tr>'."\n";
print $htmlforlines;
}
}
else
{
print '<tr class="drag drop oddeven"><td class="left"><span class="opacitymedium">'.$langs->trans("Empty").'</span></td><td></td><td></td><td></td></tr>';
print $htmlforlines;
} }
} }

View File

@ -170,7 +170,7 @@ else print "var received=0;";
} }
console.log("We click on the payment mode to pay amount = "+amountpayed); console.log("We click on the payment mode to pay amount = "+amountpayed);
parent.$("#poslines").load("invoice.php?place=<?php echo $place;?>&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid, function() { parent.$("#poslines").load("invoice.php?place=<?php echo $place;?>&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid, function() {
parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight); //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
parent.$.colorbox.close(); parent.$.colorbox.close();
}); });
} }

View File

@ -66,9 +66,9 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
<?php <?php
$categories = $categorie->get_full_arbo('product', 0, (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)?$conf->global->TAKEPOS_ROOT_CATEGORY_ID:0)); $categories = $categorie->get_full_arbo('product', 0, (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)?$conf->global->TAKEPOS_ROOT_CATEGORY_ID:0));
//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
// Search root category to know its level // Search root category to know its level
//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
$levelofrootcategory=0; $levelofrootcategory=0;
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)
{ {
@ -267,7 +267,7 @@ function ClickProduct(position) {
function deleteline() { function deleteline() {
$("#poslines").load("invoice.php?action=deleteline&place="+place+"&idline="+selectedline, function() { $("#poslines").load("invoice.php?action=deleteline&place="+place+"&idline="+selectedline, function() {
$('#poslines').scrollTop($('#poslines')[0].scrollHeight); //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
}); });
} }
@ -295,13 +295,13 @@ function TakeposOrderNotes() {
function Refresh() { function Refresh() {
$("#poslines").load("invoice.php?place="+place, function() { $("#poslines").load("invoice.php?place="+place, function() {
$('#poslines').scrollTop($('#poslines')[0].scrollHeight); //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
}); });
} }
function Search() { function Search() {
$("#poslines").load("invoice.php?action=search&place="+place, function() { $("#poslines").load("invoice.php?action=search&place="+place, function() {
$('#poslines').scrollTop($('#poslines')[0].scrollHeight); //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
}); });
} }
@ -334,7 +334,7 @@ function Edit(number){
if (editaction=='qty' && editnumber!=""){ if (editaction=='qty' && editnumber!=""){
$("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { $("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
editnumber=""; editnumber="";
$('#poslines').scrollTop($('#poslines')[0].scrollHeight); //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#qty").html("<?php echo $langs->trans("Qty"); ?>"); $("#qty").html("<?php echo $langs->trans("Qty"); ?>");
}); });
return; return;
@ -347,7 +347,7 @@ function Edit(number){
if (editaction=='p' && editnumber!=""){ if (editaction=='p' && editnumber!=""){
$("#poslines").load("invoice.php?action=updateprice&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { $("#poslines").load("invoice.php?action=updateprice&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
editnumber=""; editnumber="";
$('#poslines').scrollTop($('#poslines')[0].scrollHeight); //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#price").html("<?php echo $langs->trans("Price"); ?>"); $("#price").html("<?php echo $langs->trans("Price"); ?>");
}); });
return; return;
@ -360,7 +360,7 @@ function Edit(number){
if (editaction=='r' && editnumber!=""){ if (editaction=='r' && editnumber!=""){
$("#poslines").load("invoice.php?action=updatereduction&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { $("#poslines").load("invoice.php?action=updatereduction&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
editnumber=""; editnumber="";
$('#poslines').scrollTop($('#poslines')[0].scrollHeight); //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>"); $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>");
}); });
return; return;
@ -395,13 +395,13 @@ function Edit(number){
function TakeposPrintingOrder(){ function TakeposPrintingOrder(){
$("#poslines").load("invoice.php?action=order&place="+place, function() { $("#poslines").load("invoice.php?action=order&place="+place, function() {
$('#poslines').scrollTop($('#poslines')[0].scrollHeight); //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
}); });
} }
function TakeposPrintingTemp(){ function TakeposPrintingTemp(){
$("#poslines").load("invoice.php?action=temp&place="+place, function() { $("#poslines").load("invoice.php?action=temp&place="+place, function() {
$('#poslines').scrollTop($('#poslines')[0].scrollHeight); //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
}); });
} }