sub edit {
$lxdebug->enter_sub();
+ $form->{simple_save} = 0;
+
set_headings("edit");
# editing without stuff to edit? try adding it first
sub prepare_order {
$lxdebug->enter_sub();
- $form->{format} = "pdf" unless ($form->{print_and_save} && $form->{format});
- $form->{media} = "screen";
$form->{formname} = $form->{type} unless $form->{formname};
- map { $form->{$_} =~ s/\"/"/g }
- qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact);
my $i = 0;
foreach $ref (@{ $form->{form_details} }) {
$form->{rowcount} = ++$i;
sub form_header {
$lxdebug->enter_sub();
- $checkedopen = ($form->{closed}) ? "" : "checked";
- $checkedclosed = ($form->{closed}) ? "checked" : "";
+ my $checkedclosed = $form->{"closed"} ? "checked" : "";
+ my $checkeddelivered = $form->{"delivered"} ? "checked" : "";
+
+ map { $form->{$_} =~ s/\"/"/g }
+ qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname
+ shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact
+ shiptophone shiptofax shiptodepartment_1 shiptodepartment_2);
# use JavaScript Calendar or not
$form->{jsscript} = $form->{jscalendar};
$openclosed = qq|
<tr>
<td colspan=2 align=center>
- <table>
- <tr>
- <th nowrap><input name=closed type=radio class=radio value=0 $checkedopen> |
- . $locale->text('Open') . qq|</th>
- <th nowrap><input name=closed type=radio class=radio value=1 $checkedclosed> |
- . $locale->text('Closed') . qq|</th>
- </tr>
- </table>
- </td>
+ <input name="closed" id="closed" type="checkbox" class="checkbox" value="1" $checkedclosed>
+ <label for="closed">| . $locale->text('Closed') . qq|</label>
+|;
+
+ if (($form->{"type"} eq "sales_order") ||
+ ($form->{"type"} eq "purchase_order")) {
+ $openclosed .= qq|
+ <input name="delivered" id="delivered" type="checkbox" class="checkbox" value="1" $checkeddelivered>
+ <label for="delivered">| . $locale->text('Delivered') . qq|</label>
+|;
+ }
+
+ $openclosed .= qq|
+ </td>
</tr>
|;
}
if (@{ $form->{SHIPTO} }) {
$form->{selectshipto} = "<option value=0></option>";
foreach $item (@{ $form->{SHIPTO} }) {
- if ($item->{id} == $form->{shipto_id}) {
+ if ($item->{shipto_id} == $form->{shipto_id}) {
$form->{selectshipto} .=
- "<option value=$item->{id} selected>$item->{shiptoname}</option>";
+ "<option value=$item->{shipto_id} selected>$item->{shiptoname} $item->{shiptodepartment_1}</option>";
} else {
$form->{selectshipto} .=
- "<option value=$item->{id}>$item->{shiptoname}</option>";
+ "<option value=$item->{shipto_id}>$item->{shiptoname} $item->{shiptodepartment}</option>";
}
}
} else {
+ $form->{selectshipto} = $form->unquote($form->{selectshipto});
$form->{selectshipto} =~ s/ selected//g;
if ($form->{shipto_id} ne "") {
$form->{selectshipto} =~ s/value=$form->{shipto_id}/value=$form->{shipto_id} selected/;
$shipto = qq|
<th align=right>| . $locale->text('Shipping Address') . qq|</th>
- <td><select name=shipto_id>$form->{selectshipto}</select></td>
- <input type=hidden name=selectshipto value="$form->{selectshipto}">|;
-
+ <td><select name=shipto_id style="width:200px;">$form->{selectshipto}</select></td>|;
+ $form->{selectshipto} = $form->quote($form->{selectshipto});
+ $shipto .= qq| <input type=hidden name=selectshipto value="$form->{selectshipto}">|;
$vclabel = ucfirst $form->{vc};
$vclabel = $locale->text($vclabel);
- $terms = qq|
- <tr>
- <th align=right nowrap>| . $locale->text('Terms: Net') . qq|</th>
- <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
- . $locale->text('days') . qq|</td>
- </tr>
-|;
+
if ($form->{business}) {
$business = qq|
foreach $item (@{ $form->{TAXZONE} }) {
if ($item->{id} == $form->{taxzone_id}) {
$form->{selecttaxzone} .=
- "<option value=$item->{id} selected>$item->{description}</option>";
+ "<option value=$item->{id} selected>" . H($item->{description}) .
+ "</option>";
} else {
$form->{selecttaxzone} .=
- "<option value=$item->{id}>$item->{description}</option>";
+ "<option value=$item->{id}>" . H($item->{description}) . "</option>";
}
}
} else {
$form->{selecttaxzone} =~ s/ selected//g;
if ($form->{taxzone_id} ne "") {
- $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/;
+ $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}>/value=$form->{taxzone_id} selected>/;
}
}
- if ($form->{rowcount} >0) {
- $form->{selecttaxzone} =~ /<option value=\d+ selected>.*?<\/option>/;
- $form->{selecttaxzone} = $&;
- }
-
-
$taxzone = qq|
<tr>
<th align=right>| . $locale->text('Steuersatz') . qq|</th>
<td>$form->{creditlimit}</td>
<td width=20%></td>
<th nowrap>| . $locale->text('Remaining') . qq|</th>
- <td class="plus$n">$form->{creditremaining}</td>
+ <td class="plus$n" nowrap>$form->{creditremaining}</td>
</tr>
</table>
</td>
</tr>
|;
- $terms = "";
}
$ordnumber .= qq|
$onload = qq|alert('$credittext')|;
}
+ $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
+
$form->header;
print qq|
$openclosed
$employee
$ordnumber
- $terms
</table>
</td>
</tr>
<input type=hidden name=shiptocontact value="$form->{shiptocontact}">
<input type=hidden name=shiptophone value="$form->{shiptophone}">
<input type=hidden name=shiptofax value="$form->{shiptofax}">
+<input type=hidden name=shiptodepartment_1 value="$form->{shiptodepartment_1}">
+<input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}">
<input type=hidden name=shiptoemail value="$form->{shiptoemail}">
<!-- email variables -->
</table>
| . $locale->text("Edit the $form->{type}") . qq|<br>
-<input class=submit type=submit name=action value="|
+<input class=submit type=submit name=action id=update_button value="|
. $locale->text('Update') . qq|">
<input class=submit type=submit name=action value="|
. $locale->text('Ship to') . qq|">
<input class=submit type=submit name=action value="|
. $locale->text('Sales Order') . qq|">
<input class=submit type=submit name=action value="|
- . $locale->text('Quotation') . qq|">
+ . $locale->text('Request for Quotation') . qq|">
|;
} else {
|;
}
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
print qq|
<input type=hidden name=rowcount value=$form->{rowcount}>
} else {
- $form->{"selected_unit_$i"} = $form->{"unit_$i"};
-
if ( $form->{type} eq 'purchase_order'
|| $form->{type} eq 'request_quotation') {
IR->retrieve_item(\%myconfig, \%$form);
|;
}
+ my $delivered;
+ if (($form->{"type"} eq "sales_order") ||
+ ($form->{"type"} eq "purchase_order")) {
+ $delivered = qq|
+ <tr>
+ <td><input name="notdelivered" id="notdelivered" class="checkbox" type="checkbox" value="1" checked>
+ <label for="notdelivered">|. $locale->text('Not delivered') . qq|</label></td>
+ <td><input name="delivered" id="delivered" class="checkbox" type="checkbox" value="1" checked>
+ <label for="delivered">| . $locale->text('Delivered') . qq|</label></td>
+ </tr>
+|;
+ }
+
# use JavaScript Calendar or not
$form->{jsscript} = $jscalendar;
$jsscript = "";
<td colspan=5>
<table>
$openclosed
+ $delivered
<tr>
<td><input name="l_id" class=checkbox type=checkbox value=Y>
| . $locale->text('ID') . qq|</td>
# construct href
$href =
- "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}&$ordnumber=$number&$form->{vc}=$name&department=$department&warehouse=$warehouse";
+ "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}¬delivered=$form->{notdelivered}&delivered=$form->{delivered}&$ordnumber=$number&$form->{vc}=$name&department=$department&warehouse=$warehouse";
# construct callback
$number = $form->escape($form->{$ordnumber}, 1);
$warehouse = $form->escape($form->{warehouse}, 1);
$callback =
- "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}&$ordnumber=$number&$form->{vc}=$name&department=$department&warehouse=$warehouse";
+ "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}¬delivered=$form->{notdelivered}&delivered=$form->{delivered}&$ordnumber=$number&$form->{vc}=$name&department=$department&warehouse=$warehouse";
@columns =
$form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
"name", "netamount", "tax", "amount",
"curr", "employee", "shipvia", "open",
- "closed");
+ "closed", "delivered");
$form->{l_open} = $form->{l_closed} = "Y"
if ($form->{open} && $form->{closed});
+ $form->{"l_delivered"} = "Y"
+ if ($form->{"delivered"} && $form->{"notdelivered"});
+
foreach $item (@columns) {
if ($form->{"l_$item"} eq "Y") {
push @column_index, $item;
. qq|</a></th>|;
$column_header{quonumber} =
qq|<th><a class=listheading href=$href&sort=quonumber>|
- . $locale->text('Quotation')
+ . ($form->{"type"} eq "request_quotation" ?
+ $locale->text('RFQ') :
+ $locale->text('Quotation'))
. qq|</a></th>|;
$column_header{name} =
qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
$column_header{closed} =
qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
+ $column_header{"delivered"} =
+ qq|<th class="listheading">| . $locale->text("Delivered") . qq|</th>|;
$column_header{employee} =
qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
$column_data{closed} = "<td> </td>";
$column_data{open} = "<td align=center>X</td>";
}
+ $column_data{"delivered"} = "<td>" .
+ ($oe->{"delivered"} ? $locale->text("Yes") : $locale->text("No")) .
+ "</td>";
$i++;
$i %= 2;
. $locale->text('Add') . qq|">|;
}
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
print qq|
</form>
}
# get new number in sequence if no number is given or if saveasnew was requested
- if (!$form->{$ordumber} || $form->{saveasnew}) {
+ if (!$form->{$ordnumber} || $form->{saveasnew}) {
$form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld);
}
+ relink_accounts();
+
$form->redirect(
$form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
if (OE->save(\%myconfig, \%$form));
$form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
unless $form->{$ordnumber};
+ relink_accounts();
OE->save(\%myconfig, \%$form);
$form->{simple_save} = 1;
# also copy deliverydate from the order
$form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
+ $form->{orddate} = $form->{transdate};
} else {
$form->isblank("quonumber", $locale->text('Quotation Number missing!'));
$form->isblank("transdate", $locale->text('Quotation Date missing!'));
$form->{ordnumber} = "";
+ $form->{quodate} = $form->{transdate};
}
# if the name changed get new values
$form->{cp_id} *= 1;
+ for $i (1 .. $form->{rowcount}) {
+ map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
+ $form->{"${_}_${i}"})
+ if ($form->{"${_}_${i}"}) }
+ qw(ship qty sellprice listprice basefactor));
+ }
+
if ( $form->{type} =~ /_order/
&& $form->{currency} ne $form->{defaultcurrency}) {
# if not it's most likely a collective order, which can't be saved back
# so they just have to be closed
if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
- OE->save(\%myconfig, \%$form);
+ OE->close_order(\%myconfig, \%$form);
} else {
OE->close_orders(\%myconfig, \%$form);
}
} qw(sellprice discount);
}
+ relink_accounts();
+
OE->save(\%myconfig, \%$form);
# rebuild rows for invoice
if ( $form->{type} eq 'sales_quotation'
|| $form->{type} eq 'request_quotation') {
- $form->{closed} = 1;
- OE->save(\%myconfig, \%$form);
+ OE->close_order(\%myconfig, \%$form);
}
$form->{cp_id} *= 1;
if ( $form->{type} eq 'sales_quotation'
|| $form->{type} eq 'request_quotation') {
- $form->{closed} = 1;
- OE->save(\%myconfig, \%$form);
+ OE->close_order(\%myconfig, $form);
}
$form->{cp_id} *= 1;
map { delete $form->{$_} }
qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
+ for $i (1 .. $form->{rowcount}) {
+ map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
+ $form->{"${_}_${i}"})
+ if ($form->{"${_}_${i}"}) }
+ qw(ship qty sellprice listprice basefactor));
+ }
+
&order_links;
&prepare_order;
<input type=hidden name=shiptophone value="$form->{shiptophone}">
<input type=hidden name=shiptofax value="$form->{shiptofax}">
<input type=hidden name=shiptoemail value="$form->{shiptoemail}">
+<input type=hidden name=shiptodepartment_1 value="$form->{shiptodepartment_1}">
+<input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}">
<!-- email variables -->
<input type=hidden name=message value="$form->{message}">
<input class=submit type=submit name=action value="|
. $locale->text('Done') . qq|">
-|;
-
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
- print qq|
<input type=hidden name=rowcount value=$form->{rowcount}>
<input type=hidden name=password value=$form->{password}>
<input class=submit type=submit name=action value="|
- . $locale->text('Transfer') . qq|">|;
+ . $locale->text('Transfer') . qq|">
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
- print qq|
</form>
</body>