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

Version 1.2: Create invoice number only when an invoice should be generated

parent b7e65031
No related branches found
No related tags found
No related merge requests found
BASE=ordernumber BASE=ordernumber
PLUGINTYPE=vmshopper PLUGINTYPE=vmshopper
VERSION=1.1 VERSION=1.2
PLUGINFILES=$(BASE).php $(BASE).xml index.html PLUGINFILES=$(BASE).php $(BASE).xml index.html
TRANSDIR=../../../administrator/language/ # TRANSDIR=../../../administrator/language/
TRANSLATIONS=$(call wildcard,$(TRANSDIR)/*/*.plg_$(PLUGINTYPE)_$(BASE).sys.ini) # TRANSLATIONS=$(call wildcard,$(TRANSDIR)/*/*.plg_$(PLUGINTYPE)_$(BASE).sys.ini)
TRANSLATIONS=$(call wildcard,*.plg_$(PLUGINTYPE)_$(BASE).sys.ini)
ZIPFILE=plg_$(PLUGINTYPE)_$(BASE)_v$(VERSION).zip ZIPFILE=plg_$(PLUGINTYPE)_$(BASE)_v$(VERSION).zip
zip: $(PLUGINFILES) $(TRANSLATIONS) zip: $(PLUGINFILES) $(TRANSLATIONS)
......
...@@ -49,7 +49,6 @@ PLG_ORDERNUMBER_ORDERNR_CUSTOMIZE = "Bestellungsnummern anpassen" ...@@ -49,7 +49,6 @@ PLG_ORDERNUMBER_ORDERNR_CUSTOMIZE = "Bestellungsnummern anpassen"
PLG_ORDERNUMBER_ORDERNR_CUSTOMIZE_DESC = "Hier ankreuzen, wenn Sie Ihre Bestellungsnummern anpassen möchten und nicht die Standardeinstellung benutzen möchten." PLG_ORDERNUMBER_ORDERNR_CUSTOMIZE_DESC = "Hier ankreuzen, wenn Sie Ihre Bestellungsnummern anpassen möchten und nicht die Standardeinstellung benutzen möchten."
PLG_ORDERNUMBER_ORDERNR_FMT="Format der Bestellungsnummern" PLG_ORDERNUMBER_ORDERNR_FMT="Format der Bestellungsnummern"
PLG_ORDERNUMBER_ORDERNR_FMT_DESC="Hier können Sie Ihr eigenes Format für Bestellungsnummern angeben." PLG_ORDERNUMBER_ORDERNR_FMT_DESC="Hier können Sie Ihr eigenes Format für Bestellungsnummern angeben."
PLG_ORDERNUMBER_ORDERNR_FMT_DEFAULT = "Order-[year][month]-#"
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."
...@@ -58,14 +57,11 @@ PLG_ORDERNUMBER_PASSWD_CUSTOMIZE = "Bestellungspasswort anpassen" ...@@ -58,14 +57,11 @@ PLG_ORDERNUMBER_PASSWD_CUSTOMIZE = "Bestellungspasswort anpassen"
PLG_ORDERNUMBER_PASSWD_CUSTOMIZE_DESC = "Hier ankreuzen, wenn Sie Ihre Bestellungspasswörter anpassen möchten und nicht die Standardeinstellung benutzen möchten." PLG_ORDERNUMBER_PASSWD_CUSTOMIZE_DESC = "Hier ankreuzen, wenn Sie Ihre Bestellungspasswörter anpassen möchten und nicht die Standardeinstellung benutzen möchten."
PLG_ORDERNUMBER_PASSWD_FMT = "Format of the order password" PLG_ORDERNUMBER_PASSWD_FMT = "Format of the order password"
PLG_ORDERNUMBER_PASSWD_FMT_DESC = "Hier können Sie Ihr eigenes Format für Bestellungspasswörter angeben (# wird nicht ersetzt)." PLG_ORDERNUMBER_PASSWD_FMT_DESC = "Hier können Sie Ihr eigenes Format für Bestellungspasswörter angeben (# wird nicht ersetzt)."
PLG_ORDERNUMBER_PASSWD_FMT_DEFAULT = "p_[randomHex5]"
PLG_ORDERNUMBER_INVOICENR = "<b>Rechnungsnummern</b>" PLG_ORDERNUMBER_INVOICENR = "<b>Rechnungsnummern</b>"
PLG_ORDERNUMBER_INVOICENR_CUSTOMIZE = "Rechnungsnummern anpassen" PLG_ORDERNUMBER_INVOICENR_CUSTOMIZE = "Rechnungsnummern anpassen"
PLG_ORDERNUMBER_INVOICENR_CUSTOMIZE_DESC = "Hier ankreuzen, wenn Sie Ihre Rechnungsnummern anpassen möchten und nicht die Standardeinstellung benutzen möchten." PLG_ORDERNUMBER_INVOICENR_CUSTOMIZE_DESC = "Hier ankreuzen, wenn Sie Ihre Rechnungsnummern anpassen möchten und nicht die Standardeinstellung benutzen möchten."
PLG_ORDERNUMBER_INVOICENR_FMT = "Format der Rechnungsnummern" 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_FMT_DEFAULT = "[year]/#"
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."
...@@ -49,7 +49,6 @@ PLG_ORDERNUMBER_ORDERNR_CUSTOMIZE = "Customize order numbers" ...@@ -49,7 +49,6 @@ PLG_ORDERNUMBER_ORDERNR_CUSTOMIZE = "Customize order numbers"
PLG_ORDERNUMBER_ORDERNR_CUSTOMIZE_DESC = "Check here if you want customized order number formats rather than the default." PLG_ORDERNUMBER_ORDERNR_CUSTOMIZE_DESC = "Check here if you want customized order number formats rather than the default."
PLG_ORDERNUMBER_ORDERNR_FMT="Format of the order numbers" 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_FMT_DEFAULT = "Order-[year][month]-#"
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."
...@@ -58,14 +57,11 @@ PLG_ORDERNUMBER_PASSWD_CUSTOMIZE = "Customize order password" ...@@ -58,14 +57,11 @@ PLG_ORDERNUMBER_PASSWD_CUSTOMIZE = "Customize order password"
PLG_ORDERNUMBER_PASSWD_CUSTOMIZE_DESC = "Check here if you want customized order password formats rather than the default." PLG_ORDERNUMBER_PASSWD_CUSTOMIZE_DESC = "Check here if you want customized order password formats rather than the default."
PLG_ORDERNUMBER_PASSWD_FMT = "Format of the order password" PLG_ORDERNUMBER_PASSWD_FMT = "Format of the order password"
PLG_ORDERNUMBER_PASSWD_FMT_DESC = "Here you can customize the order password (# is NOT replaced)" PLG_ORDERNUMBER_PASSWD_FMT_DESC = "Here you can customize the order password (# is NOT replaced)"
PLG_ORDERNUMBER_PASSWD_FMT_DEFAULT = "p_[randomHex5]"
PLG_ORDERNUMBER_INVOICENR = "<b>Invoice numbers</b>" PLG_ORDERNUMBER_INVOICENR = "<b>Invoice numbers</b>"
PLG_ORDERNUMBER_INVOICENR_CUSTOMIZE = "Customize invoice numbers" PLG_ORDERNUMBER_INVOICENR_CUSTOMIZE = "Customize invoice numbers"
PLG_ORDERNUMBER_INVOICENR_CUSTOMIZE_DESC = "Check here if you want customized invoice number formats rather than the default." PLG_ORDERNUMBER_INVOICENR_CUSTOMIZE_DESC = "Check here if you want customized invoice number formats rather than the default."
PLG_ORDERNUMBER_INVOICENR_FMT = "Format of the invoice numbers" 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_FMT_DEFAULT = "[year]/#"
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."
...@@ -25,17 +25,17 @@ class plgVmShopperOrdernumber extends vmShopperPlugin { ...@@ -25,17 +25,17 @@ class plgVmShopperOrdernumber extends vmShopperPlugin {
function getTableSQLFields () { function getTableSQLFields () {
$SQLfields = array( $SQLfields = array(
'id' => 'int(11) UNSIGNED NOT NULL AUTO_INCREMENT', 'id' => 'int(11) UNSIGNED NOT NULL AUTO_INCREMENT',
'number_type' => 'int(1) UNSIGNED', 'number_type' => 'int(1) UNSIGNED',
'number_format' => 'varchar(255)', 'number_format' => 'varchar(255)',
'count' => 'int(1)', 'count' => 'int(1)',
); );
return $SQLfields; return $SQLfields;
} }
// We don't need this function, but the parent class declares it abstract, so we need to overload // We don't need this function, but the parent class declares it abstract, so we need to overload
function plgVmOnUpdateOrderBEShopper($_orderID) {} function plgVmOnUpdateOrderBEShopper($_orderID) {}
/* Return a random "string" of the given length taken from the given alphabet */ /* Return a random "string" of the given length taken from the given alphabet */
static function randomString($alphabet, $len) { static function randomString($alphabet, $len) {
$alen = strlen($alphabet); $alen = strlen($alphabet);
...@@ -116,7 +116,7 @@ class plgVmShopperOrdernumber extends vmShopperPlugin { ...@@ -116,7 +116,7 @@ class plgVmShopperOrdernumber extends vmShopperPlugin {
$db->setQuery($q); $db->setQuery($q);
$existing = $db->loadResult(); $existing = $db->loadResult();
$count = $existing?($existing+1):1; $count = $existing?($existing+1):1;
// Insert new counter value into the db // Insert new counter value into the db
if ($existing) { if ($existing) {
$q = 'UPDATE `'.$this->_tablename.'` SET `count`= "'.$count.'" WHERE `number_type`='.(int)$nrtype.' AND `number_format`="'.($global?"":$nr_escaped).'"'; $q = 'UPDATE `'.$this->_tablename.'` SET `count`= "'.$count.'" WHERE `number_type`='.(int)$nrtype.' AND `number_format`="'.($global?"":$nr_escaped).'"';
...@@ -137,7 +137,7 @@ class plgVmShopperOrdernumber extends vmShopperPlugin { ...@@ -137,7 +137,7 @@ 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); $ordernr = $this->format_number ($fmt, $orderDetails, $nrtype, $global);
$orderDetails->order_number = $ordernr; $orderDetails->order_number = $ordernr;
} }
// Is order password customization enabled? // Is order password customization enabled?
...@@ -147,15 +147,25 @@ class plgVmShopperOrdernumber extends vmShopperPlugin { ...@@ -147,15 +147,25 @@ class plgVmShopperOrdernumber extends vmShopperPlugin {
$orderDetails->order_pass = $passwd; $orderDetails->order_pass = $passwd;
} }
} }
function plgVmOnUserInvoice($orderDetails,&$data) { function plgVmOnUserInvoice($orderDetails,&$data) {
// print("<pre>plgVmOnUserInvoice, orderDetails=");print_r($orderDetails);print("</pre>");
// print("<pre>plgVmOnUserInvoice, data=");print_r($data);print("</pre>");
// Is order number customization enabled? // Is order number customization enabled?
if ($this->params->get('customize_invoice_number')) { if ($this->params->get('customize_invoice_number')) {
$nrtype=1; /*invoice-nr*/ // check the default configuration
$fmt = $this->params->get ('invoice_number_format', "#"); $orderstatusForInvoice = VmConfig::get('inv_os',array());
$global = $this->params->get ('invoice_number_global', 1); if(!is_array($orderstatusForInvoice)) $orderstatusForInvoice = array($orderstatusForInvoice); //for backward compatibility 2.0.8e
$invoicenr = $this->format_number ($fmt, (object)$orderDetails, $nrtype, $global); $pdfInvoice = (int)VmConfig::get('pdf_invoice', 0); // backwards compatible
$data['invoice_number'] = $invoicenr; $force_create_invoice=JRequest::getInt('create_invoice', 0);
if ( in_array($orderDetails['order_status'],$orderstatusForInvoice) or $pdfInvoice==1 or $force_create_invoice==1 ){
$nrtype=1; /*invoice-nr*/
$fmt = $this->params->get ('invoice_number_format', "#");
$global = $this->params->get ('invoice_number_global', 1);
$invoicenr = $this->format_number ($fmt, (object)$orderDetails, $nrtype, $global);
// print("<pre> invoice nr format: $fmt, resulting in $invoicenr</pre>");
$data['invoice_number'] = $invoicenr;
}
} }
} }
} }
...@@ -11,11 +11,12 @@ ...@@ -11,11 +11,12 @@
<releaseDate>2012-11-13</releaseDate> <releaseDate>2012-11-13</releaseDate>
<releaseType>Major update</releaseType> <releaseType>Major update</releaseType>
<downloadUrl>http://www.kainhofer.com/virtuemart-2-extensions/</downloadUrl> <downloadUrl>http://www.kainhofer.com/virtuemart-2-extensions/</downloadUrl>
<description>VMSHOPPER_ORDERNUMBER_DESC</description> <description>VMSHOPPER_ORDERNUMBER_DESC</description>
<languages> <languages>
<language tag="en-GB">en-GB.plg_vmshopper_ordernumber.sys.ini</language> <language tag="en-GB">en-GB.plg_vmshopper_ordernumber.sys.ini</language>
<language tag="de-DE">de-DE.plg_vmshopper_ordernumber.sys.ini</language>
</languages> </languages>
<files> <files>
<filename plugin="ordernumber">ordernumber.php</filename> <filename plugin="ordernumber">ordernumber.php</filename>
...@@ -28,7 +29,7 @@ ...@@ -28,7 +29,7 @@
<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="order_number_format" type="text" default="PLG_ORDERNUMBER_ORDERNR_FMT_DEFAULT" 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_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>
...@@ -39,19 +40,19 @@ ...@@ -39,19 +40,19 @@
<option value="1">Yes</option> <option value="1">Yes</option>
<option value="0">No</option> <option value="0">No</option>
</field> </field>
<field name="order_password_format" type="text" default="PLG_ORDERNUMBER_PASSWD_FMT_DEFAULT" label="PLG_ORDERNUMBER_PASSWD_FMT" description="PLG_ORDERNUMBER_PASSWD_FMT_DESC"/> <field name="order_password_format" type="text" default="p_[randomHex5]" label="PLG_ORDERNUMBER_PASSWD_FMT" description="PLG_ORDERNUMBER_PASSWD_FMT_DESC"/>
<field name="invoice_options" type="spacer" label="PLG_ORDERNUMBER_INVOICENR" /> <field name="invoice_options" type="spacer" label="PLG_ORDERNUMBER_INVOICENR" />
<field name="customize_invoice_number" type="radio" default="0" label="PLG_ORDERNUMBER_INVOICENR_CUSTOMIZE" description="PLG_ORDERNUMBER_INVOICENR_CUSTOMIZE_DESC"> <field name="customize_invoice_number" type="radio" default="0" label="PLG_ORDERNUMBER_INVOICENR_CUSTOMIZE" description="PLG_ORDERNUMBER_INVOICENR_CUSTOMIZE_DESC">
<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="PLG_ORDERNUMBER_INVOICENR_FMT_DEFAULT" 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_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>
</field> </field>
</fieldset> </fieldset>
</fields> </fields>
</config> </config>
</install> </install>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment