Skip to content
Snippets Groups Projects
Commit ab58acb3 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Version 1.5: Implement padding the counter with zeros

parent ce6b3827
No related branches found
No related tags found
No related merge requests found
BASE=ordernumber BASE=ordernumber
PLUGINTYPE=vmshopper PLUGINTYPE=vmshopper
VERSION=1.4 VERSION=1.5
PLUGINFILES=$(BASE).php $(BASE).xml index.html PLUGINFILES=$(BASE).php $(BASE).xml index.html
# TRANSDIR=../../../administrator/language/ # TRANSDIR=../../../administrator/language/
......
...@@ -51,6 +51,8 @@ PLG_ORDERNUMBER_ORDERNR_FMT="Format der Auftragsnummern" ...@@ -51,6 +51,8 @@ PLG_ORDERNUMBER_ORDERNR_FMT="Format der Auftragsnummern"
PLG_ORDERNUMBER_ORDERNR_FMT_DESC="Hier können Sie Ihr eigenes Format für Auftragsnummern angeben." PLG_ORDERNUMBER_ORDERNR_FMT_DESC="Hier können Sie Ihr eigenes Format für Auftragsnummern angeben."
PLG_ORDERNUMBER_ORDERNR_COUNTER = "Zähler" PLG_ORDERNUMBER_ORDERNR_COUNTER = "Zähler"
PLG_ORDERNUMBER_ORDERNR_COUNTER_DESC = "Wählen Sie aus, ob der Zähler global oder pro Formatwert laufen soll. Z.B. beginnt bei einem Format '[year]-#' und einem Zähler pro Formatwert der Zähler jedes Jahr bei 1." PLG_ORDERNUMBER_ORDERNR_COUNTER_DESC = "Wählen Sie aus, ob der Zähler global oder pro Formatwert laufen soll. Z.B. beginnt bei einem Format '[year]-#' und einem Zähler pro Formatwert der Zähler jedes Jahr bei 1."
PLG_ORDERNUMBER_ORDERNR_PADDING = "Mindestziffern für den Zähler"
PLG_ORDERNUMBER_ORDERNR_PADDING_DESC = "Wählen Sie hier die Mindestzahl von Ziffern, die der Zähler anzeigt. Ist der Wert des Zählers kleiner, werden entsprechend viele führende Nullen vorangestellt."
PLG_ORDERNUMBER_PASSWD = "<b>Auftragspasswort</b>" PLG_ORDERNUMBER_PASSWD = "<b>Auftragspasswort</b>"
PLG_ORDERNUMBER_PASSWD_CUSTOMIZE = "Auftragspasswort anpassen" PLG_ORDERNUMBER_PASSWD_CUSTOMIZE = "Auftragspasswort anpassen"
...@@ -65,3 +67,5 @@ PLG_ORDERNUMBER_INVOICENR_FMT = "Format der Rechnungsnummern" ...@@ -65,3 +67,5 @@ PLG_ORDERNUMBER_INVOICENR_FMT = "Format der Rechnungsnummern"
PLG_ORDERNUMBER_INVOICENR_FMT_DESC = "Hier können Sie Ihr eigenes Format für Rechnungsnummern angeben." PLG_ORDERNUMBER_INVOICENR_FMT_DESC = "Hier können Sie Ihr eigenes Format für Rechnungsnummern angeben."
PLG_ORDERNUMBER_INVOICENR_COUNTER = "Zähler" PLG_ORDERNUMBER_INVOICENR_COUNTER = "Zähler"
PLG_ORDERNUMBER_INVOICENR_COUNTER_DESC = "Wählen Sie aus, ob der Zähler global oder pro Formatwert laufen soll. Z.B. beginnt bei einem Format '[year]-#' und einem Zähler pro Formatwert der Zähler jedes Jahr bei 1." PLG_ORDERNUMBER_INVOICENR_COUNTER_DESC = "Wählen Sie aus, ob der Zähler global oder pro Formatwert laufen soll. Z.B. beginnt bei einem Format '[year]-#' und einem Zähler pro Formatwert der Zähler jedes Jahr bei 1."
PLG_ORDERNUMBER_INVOICENR_PADDING = "Mindestziffern für den Zähler"
PLG_ORDERNUMBER_INVOICENR_PADDING_DESC = "Wählen Sie hier die Mindestzahl von Ziffern, die der Zähler anzeigt. Ist der Wert des Zählers kleiner, werden entsprechend viele führende Nullen vorangestellt."
...@@ -51,6 +51,8 @@ PLG_ORDERNUMBER_ORDERNR_FMT="Format of the order numbers" ...@@ -51,6 +51,8 @@ PLG_ORDERNUMBER_ORDERNR_FMT="Format of the order numbers"
PLG_ORDERNUMBER_ORDERNR_FMT_DESC="Here you can customize the order number" PLG_ORDERNUMBER_ORDERNR_FMT_DESC="Here you can customize the order number"
PLG_ORDERNUMBER_ORDERNR_COUNTER = "Counter" PLG_ORDERNUMBER_ORDERNR_COUNTER = "Counter"
PLG_ORDERNUMBER_ORDERNR_COUNTER_DESC = "Choose whether you want one global counter or per-format value counters. E.g. with a format of '[year]-#' and the latter option checked, the order count will be within the year only." PLG_ORDERNUMBER_ORDERNR_COUNTER_DESC = "Choose whether you want one global counter or per-format value counters. E.g. with a format of '[year]-#' and the latter option checked, the order count will be within the year only."
PLG_ORDERNUMBER_ORDERNR_PADDING = "Minimum digits for the counter"
PLG_ORDERNUMBER_ORDERNR_PADDING_DESC = "Select the minimum number of digits that the counter shall display. The value of the counter will be left-padded with 0 to have this minimum number of digits. If the counter is already larger than this number, no padding will occur"
PLG_ORDERNUMBER_PASSWD = "<b>Order password</b>" PLG_ORDERNUMBER_PASSWD = "<b>Order password</b>"
PLG_ORDERNUMBER_PASSWD_CUSTOMIZE = "Customize order password" PLG_ORDERNUMBER_PASSWD_CUSTOMIZE = "Customize order password"
...@@ -65,3 +67,5 @@ PLG_ORDERNUMBER_INVOICENR_FMT = "Format of the invoice numbers" ...@@ -65,3 +67,5 @@ PLG_ORDERNUMBER_INVOICENR_FMT = "Format of the invoice numbers"
PLG_ORDERNUMBER_INVOICENR_FMT_DESC = "Here you can customize the invoice number" PLG_ORDERNUMBER_INVOICENR_FMT_DESC = "Here you can customize the invoice number"
PLG_ORDERNUMBER_INVOICENR_COUNTER = "Counter" PLG_ORDERNUMBER_INVOICENR_COUNTER = "Counter"
PLG_ORDERNUMBER_INVOICENR_COUNTER_DESC = "Choose whether you want one global counter or per-format value counters. E.g. with a format of '[year]-#' and the latter option checked, the invoice count will be within the year only." PLG_ORDERNUMBER_INVOICENR_COUNTER_DESC = "Choose whether you want one global counter or per-format value counters. E.g. with a format of '[year]-#' and the latter option checked, the invoice count will be within the year only."
PLG_ORDERNUMBER_INVOICENR_PADDING = "Minimum digits for the counter"
PLG_ORDERNUMBER_INVOICENR_PADDING_DESC = "Select the minimum number of digits that the counter shall display. The value of the counter will be left-padded with 0 to have this minimum number of digits. If the counter is already larger than this number, no padding will occur"
images/plg_vmshopper_ordernumber_Order.png

14.8 KiB

images/plg_vmshopper_ordernumber_Parameters.png

33.5 KiB

images/plg_vmshopper_ordernumber_Plugindescription.png

112 KiB

...@@ -128,7 +128,7 @@ class plgVmShopperOrdernumber extends vmShopperPlugin { ...@@ -128,7 +128,7 @@ class plgVmShopperOrdernumber extends vmShopperPlugin {
} }
/* Type 0 means order number, type 1 means invoice number */ /* Type 0 means order number, type 1 means invoice number */
function format_number ($fmt, $orderDetails, $nrtype = 0, $global = 1) { function format_number ($fmt, $orderDetails, $nrtype = 0, $global = 1, $padding = 1) {
// First, replace all variables: // First, replace all variables:
$nr = $this->replace_fields ($fmt, $orderDetails); $nr = $this->replace_fields ($fmt, $orderDetails);
...@@ -152,7 +152,8 @@ class plgVmShopperOrdernumber extends vmShopperPlugin { ...@@ -152,7 +152,8 @@ class plgVmShopperOrdernumber extends vmShopperPlugin {
$db->query(); $db->query();
// return the format with the counter inserted // return the format with the counter inserted
return str_replace ("#", $count, $nr);
return str_replace ("#", sprintf('%0' . $padding . 's', $count), $nr);
} }
...@@ -162,7 +163,8 @@ class plgVmShopperOrdernumber extends vmShopperPlugin { ...@@ -162,7 +163,8 @@ class plgVmShopperOrdernumber extends vmShopperPlugin {
$nrtype=0; /*order-nr*/ $nrtype=0; /*order-nr*/
$fmt = $this->params->get ('order_number_format', "#"); $fmt = $this->params->get ('order_number_format', "#");
$global = $this->params->get ('order_number_global', 1); $global = $this->params->get ('order_number_global', 1);
$ordernr = $this->format_number ($fmt, $orderDetails, $nrtype, $global); $padding = $this->params->get ('order_number_padding', 1);
$ordernr = $this->format_number ($fmt, $orderDetails, $nrtype, $global, $padding);
$orderDetails->order_number = $ordernr; $orderDetails->order_number = $ordernr;
} }
// Is order password customization enabled? // Is order password customization enabled?
...@@ -185,7 +187,8 @@ class plgVmShopperOrdernumber extends vmShopperPlugin { ...@@ -185,7 +187,8 @@ class plgVmShopperOrdernumber extends vmShopperPlugin {
$nrtype=1; /*invoice-nr*/ $nrtype=1; /*invoice-nr*/
$fmt = $this->params->get ('invoice_number_format', "#"); $fmt = $this->params->get ('invoice_number_format', "#");
$global = $this->params->get ('invoice_number_global', 1); $global = $this->params->get ('invoice_number_global', 1);
$invoicenr = $this->format_number ($fmt, (object)$orderDetails, $nrtype, $global); $padding = $this->params->get ('invoice_number_padding', 1);
$invoicenr = $this->format_number ($fmt, (object)$orderDetails, $nrtype, $global, $padding);
$data['invoice_number'] = $invoicenr; $data['invoice_number'] = $invoicenr;
} }
} }
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
<authorUrl>http://www.kainhofer.com/</authorUrl> <authorUrl>http://www.kainhofer.com/</authorUrl>
<copyright>Copyright (C) 2012 Reinhold Kainhofer. All rights reserved.</copyright> <copyright>Copyright (C) 2012 Reinhold Kainhofer. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3</license> <license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3</license>
<version>1.4.0</version> <version>1.5.0</version>
<releaseDate>2012-11-13</releaseDate> <releaseDate>2012-12-16</releaseDate>
<releaseType>Minor update</releaseType> <releaseType>Minor update</releaseType>
<downloadUrl>http://www.kainhofer.com/virtuemart-2-extensions/</downloadUrl> <downloadUrl>http://www.kainhofer.com/virtuemart-2-extensions/</downloadUrl>
...@@ -30,11 +30,13 @@ ...@@ -30,11 +30,13 @@
<option value="0">PLG_ORDERNUMBER_NO</option> <option value="0">PLG_ORDERNUMBER_NO</option>
</field> </field>
<field name="order_number_format" type="text" default="Order-[year][month]-#" label="PLG_ORDERNUMBER_ORDERNR_FMT" description="PLG_ORDERNUMBER_ORDERNR_FMT_DESC"/> <field name="order_number_format" type="text" default="Order-[year][month]-#" label="PLG_ORDERNUMBER_ORDERNR_FMT" description="PLG_ORDERNUMBER_ORDERNR_FMT_DESC"/>
<field name="order_number_padding" type="integer" default="1" label="PLG_ORDERNUMBER_ORDERNR_PADDING" description="PLG_ORDERNUMBER_ORDERNR_PADDING_DESC" first="1" last="10" step="1" />
<field name="order_number_global" type="radio" default="0" label="PLG_ORDERNUMBER_ORDERNR_COUNTER" description="PLG_ORDERNUMBER_ORDERNR_COUNTER_DESC"> <field name="order_number_global" type="radio" default="0" label="PLG_ORDERNUMBER_ORDERNR_COUNTER" description="PLG_ORDERNUMBER_ORDERNR_COUNTER_DESC">
<option value="1">PLG_ORDERNUMBER_COUNTER_GLOBAL</option> <option value="1">PLG_ORDERNUMBER_COUNTER_GLOBAL</option>
<option value="0">PLG_ORDERNUMBER_COUNTER_PERFORMAT</option> <option value="0">PLG_ORDERNUMBER_COUNTER_PERFORMAT</option>
</field> </field>
<field name="password_options" type="spacer" label="PLG_ORDERNUMBER_PASSWD" /> <field name="password_options" type="spacer" label="PLG_ORDERNUMBER_PASSWD" />
<field name="customize_order_password" type="radio" default="0" label="PLG_ORDERNUMBER_PASSWD_CUSTOMIZE" description="PLG_ORDERNUMBER_PASSWD_CUSTOMIZE_DESC"> <field name="customize_order_password" type="radio" default="0" label="PLG_ORDERNUMBER_PASSWD_CUSTOMIZE" description="PLG_ORDERNUMBER_PASSWD_CUSTOMIZE_DESC">
<option value="1">Yes</option> <option value="1">Yes</option>
...@@ -47,7 +49,8 @@ ...@@ -47,7 +49,8 @@
<option value="1">PLG_ORDERNUMBER_YES</option> <option value="1">PLG_ORDERNUMBER_YES</option>
<option value="0">PLG_ORDERNUMBER_NO</option> <option value="0">PLG_ORDERNUMBER_NO</option>
</field> </field>
<field name="invoice_number_format" type="text" default="[year]-#" label="PLG_ORDERNUMBER_INVOICENR_FMT" description="PLG_ORDERNUMBER_INVOICENR_FMT_DESC"/> <field name="invoice_number_format" type="text" default="[year]-#" label="PLG_ORDERNUMBER_INVOICENR_FMT" description="PLG_ORDERNUMBER_INVOICENR_FMT_DESC"/>
<field name="invoice_number_padding" type="integer" default="1" label="PLG_ORDERNUMBER_INVOICENR_PADDING" description="PLG_ORDERNUMBER_INVOICENR_PADDING_DESC" first="1" last="10" step="1" />
<field name="invoice_number_global" type="radio" default="0" label="PLG_ORDERNUMBER_INVOICENR_COUNTER" description="PLG_ORDERNUMBER_INVOICENR_COUNTER_DESC"> <field name="invoice_number_global" type="radio" default="0" label="PLG_ORDERNUMBER_INVOICENR_COUNTER" description="PLG_ORDERNUMBER_INVOICENR_COUNTER_DESC">
<option value="1">PLG_ORDERNUMBER_COUNTER_GLOBAL</option> <option value="1">PLG_ORDERNUMBER_COUNTER_GLOBAL</option>
<option value="0">PLG_ORDERNUMBER_COUNTER_PERFORMAT</option> <option value="0">PLG_ORDERNUMBER_COUNTER_PERFORMAT</option>
......
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment