Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SAMBUMBA
pasteque-server
Commits
a51871c2
Commit
a51871c2
authored
Jan 15, 2014
by
Cédric Houbart
Browse files
Fix base_product module
parent
f3064ff0
Changes
4
Hide whitespace changes
Inline
Side-by-side
modules/base_products/actions/productsManagement.php
View file @
a51871c2
...
...
@@ -59,10 +59,10 @@ function import_csv($csv) {
//check
$category
=
\
Pasteque\CategoriesService
::
getByName
(
$tab
[
'category'
]);
$tax
_c
at
=
\
Pasteque\TaxesService
::
getByName
(
$tab
[
'tax_cat'
]);
$tax
C
at
=
\
Pasteque\TaxesService
::
getByName
(
$tab
[
'tax_cat'
]);
if
(
$tax
_c
at
&&
$category
)
{
$prod
=
readProductLine
(
$tab
,
$category
,
$tax
_c
at
);
if
(
$tax
C
at
&&
$category
)
{
$prod
=
readProductLine
(
$tab
,
$category
,
$tax
C
at
);
$product_exist
=
\
Pasteque\ProductsService
::
getByRef
(
$prod
->
reference
);
if
(
$product_exist
!==
null
)
{
// update product
...
...
@@ -102,7 +102,7 @@ function import_csv($csv) {
.
"category: '%s' doesn't exist"
,
PLUGIN_NAME
,
$csv
->
getCurrentLineNumber
(),
$tab
[
'category'
]);
}
if
(
!
$tax
_c
at
)
{
if
(
!
$tax
C
at
)
{
$error_mess
[]
=
\
i18n
(
"On line %d: "
.
"Tax category: '%s' doesn't exist"
,
PLUGIN_NAME
,
$csv
->
getCurrentLineNumber
(),
$tab
[
'tax_cat'
]);
...
...
@@ -135,7 +135,7 @@ function readProductLine($line, $category, $taxCat) {
}
$product
=
new
\
Pasteque\Product
(
$line
[
'reference'
],
$line
[
'label'
],
$priceSell
,
$category
->
id
,
$dispOrder
,
$taxCat
,
$visible
,
$scaled
);
$taxCat
->
id
,
$visible
,
$scaled
);
if
(
isset
(
$line
[
'barcode'
]))
{
$product
->
barcode
=
$line
[
'barcode'
];
}
...
...
@@ -158,7 +158,7 @@ function readProductLine($line, $category, $taxCat) {
* else update stockDiarry and stockCurr.
*/
function
manage_stock_level
(
$id
,
$array
)
{
$level
=
\
Pasteque\StocksService
::
getLevel
(
$id
);
$level
=
\
Pasteque\StocksService
::
getLevel
(
$id
,
"0"
,
null
);
$min
=
null
;
$max
=
null
;
if
(
isset
(
$array
[
'stock_min'
]))
{
...
...
@@ -178,7 +178,7 @@ function manage_stock_level($id, $array) {
return
\
Pasteque\StocksService
::
updateLevel
(
$level
);
}
else
{
// Create a new level
$level
=
new
\
Pasteque\StockLevel
(
$id
,
"0
00"
,
$min
,
$max
);
$level
=
new
\
Pasteque\StockLevel
(
$id
,
"0
"
,
null
,
$min
,
$max
);
return
\
Pasteque\StocksService
::
createLevel
(
$level
);
}
}
...
...
modules/base_products/actions/tax_edit.php
View file @
a51871c2
...
...
@@ -29,6 +29,10 @@ if (isset($_POST['id'])) {
// Update tax category
$taxCat
=
\
Pasteque\TaxCat
::
__build
(
$_POST
[
'id'
],
$_POST
[
'label'
]);
$taxCatId
=
\
Pasteque\TaxesService
::
updateCat
(
$taxCat
);
if
(
$taxCatId
===
false
)
{
$error
=
\
i18n
(
"Unable to save tax."
,
PLUGIN_NAME
);
// Continue as taxes can be updated anyway
}
// rebuild tax rates
$taxValues
=
array
();
foreach
(
$_POST
as
$key
=>
$value
)
{
...
...
@@ -49,7 +53,9 @@ if (isset($_POST['id'])) {
foreach
(
$taxValues
as
$id
=>
$data
)
{
$tax
=
\
Pasteque\Tax
::
__build
(
$id
,
$taxCat
->
id
,
$data
[
'label'
],
$data
[
'startDate'
],
floatval
(
$data
[
'rate'
]));
\
Pasteque\TaxesService
::
updateTax
(
$tax
);
if
(
!
\
Pasteque\TaxesService
::
updateTax
(
$tax
))
{
$error
=
\
i18n
(
"Unable to save tax."
,
PLUGIN_NAME
);
}
}
// new tax rate?
if
(
isset
(
$_POST
[
'label-new'
])
&&
isset
(
$_POST
[
'rate-new'
]))
{
...
...
@@ -60,7 +66,12 @@ if (isset($_POST['id'])) {
}
$tax
=
new
\
Pasteque\Tax
(
$_POST
[
'id'
],
$_POST
[
'label-new'
],
$start
,
floatval
(
$_POST
[
'rate-new'
]));
\
Pasteque\TaxesService
::
createTax
(
$tax
);
if
(
!
\
Pasteque\TaxesService
::
createTax
(
$tax
))
{
$error
=
\
i18n
(
"Unable to save tax."
,
PLUGIN_NAME
);
}
}
if
(
$error
===
null
)
{
$message
=
\
i18n
(
"Tax saved"
,
PLUGIN_NAME
);
}
}
else
if
(
isset
(
$_POST
[
'label'
]))
{
// Create tax category
...
...
@@ -74,15 +85,19 @@ if (isset($_POST['id'])) {
}
else
{
$start
=
\
i18nRevDate
(
$_POST
[
'new-startDate'
]);
}
$tax
=
new
\
Pasteque\Tax
(
$taxCatId
,
$_POST
[
'new-label'
],
$start
,
floatval
(
$_POST
[
'new-rate'
]));
\
Pasteque\TaxesService
::
createTax
(
$tax
);
$tax
=
new
\
Pasteque\Tax
(
$taxCatId
,
$_POST
[
'label-new'
],
$start
,
floatval
(
$_POST
[
'rate-new'
]));
if
(
\
Pasteque\TaxesService
::
createTax
(
$tax
))
{
$message
=
\
i18n
(
"Tax saved"
,
PLUGIN_NAME
);
}
else
{
$error
=
\
i18n
(
"Unable to save tax."
,
PLUGIN_NAME
);
}
}
}
$tax
_c
at
=
null
;
$tax
C
at
=
null
;
if
(
isset
(
$_GET
[
'id'
]))
{
$tax
_c
at
=
\
Pasteque\TaxesService
::
get
(
$_GET
[
'id'
]);
$tax
C
at
=
\
Pasteque\TaxesService
::
get
(
$_GET
[
'id'
]);
}
?>
<h1>
<?php
\
pi18n
(
"Edit tax"
,
PLUGIN_NAME
);
?>
</h1>
...
...
@@ -93,8 +108,8 @@ if (isset($_GET['id'])) {
<form
class=
"edit"
action=
"
<?php
echo
\
Pasteque\get_current_url
();
?>
"
method=
"post"
>
<fieldset>
<legend>
<?php
\
pi18n
(
"TaxCategory"
);
?>
</legend>
<?php
\
Pasteque\form_hidden
(
"edit"
,
$tax
_c
at
,
"id"
);
?>
<?php
\
Pasteque\form_input
(
"edit"
,
"TaxCat"
,
$tax
_c
at
,
"label"
,
"string"
,
array
(
"required"
=>
true
));
?>
<?php
\
Pasteque\form_hidden
(
"edit"
,
$tax
C
at
,
"id"
);
?>
<?php
\
Pasteque\form_input
(
"edit"
,
"TaxCat"
,
$tax
C
at
,
"label"
,
"string"
,
array
(
"required"
=>
true
));
?>
</fieldset>
<table
cellpadding=
"0"
cellspacing=
"0"
>
<thead>
...
...
@@ -105,13 +120,13 @@ if (isset($_GET['id'])) {
</tr>
</thead>
<tbody
id=
"list"
>
<?php
foreach
(
$tax
_c
at
->
taxes
as
$tax
)
{
?>
<?php
if
(
$taxCat
!==
null
)
{
foreach
(
$tax
C
at
->
taxes
as
$tax
)
{
?>
<tr>
<td>
<?php
\
Pasteque\form_input
(
$tax
->
id
,
"Tax"
,
$tax
,
"label"
,
"string"
,
array
(
"required"
=>
true
,
"nolabel"
=>
true
,
"nameid"
=>
true
));
?>
</td>
<td>
<?php
\
Pasteque\form_input
(
$tax
->
id
,
"Tax"
,
$tax
,
"rate"
,
"float"
,
array
(
"required"
=>
true
,
"nolabel"
=>
true
,
"nameid"
=>
true
));
?>
</td>
<td>
<?php
\
Pasteque\form_input
(
$tax
->
id
,
"Tax"
,
$tax
,
"startDate"
,
"date"
,
array
(
"required"
=>
true
,
"nolabel"
=>
true
,
"nameid"
=>
true
));
?>
</td>
</tr>
<?php
}
?>
<?php
}
}
?>
<tr>
<td>
<?php
\
Pasteque\form_input
(
"new"
,
"Tax"
,
null
,
"label"
,
"string"
,
array
(
"nolabel"
=>
true
,
"nameid"
=>
true
));
?>
</td>
<td>
<?php
\
Pasteque\form_input
(
"new"
,
"Tax"
,
null
,
"rate"
,
"float"
,
array
(
"nolabel"
=>
true
,
"nameid"
=>
true
));
?>
</td>
...
...
@@ -125,8 +140,8 @@ if (isset($_GET['id'])) {
</div>
</form>
<?php
if
(
$tax
_c
at
!==
NULL
)
{
?>
<?php
if
(
$tax
C
at
!==
null
)
{
?>
<form
action=
"
<?php
echo
\
Pasteque\get_module_url_action
(
PLUGIN_NAME
,
'taxes'
);
?>
"
method=
"post"
>
<?php
\
Pasteque\form_delete
(
"taxcat"
,
$tax
_c
at
->
id
);
?>
<?php
\
Pasteque\form_delete
(
"taxcat"
,
$tax
C
at
->
id
);
?>
</form>
<?php
}
?>
modules/base_products/languages/default.locale
View file @
a51871c2
...
...
@@ -29,6 +29,8 @@
"Rates": "Rates",
"New tax rate": "New rate",
"Unable to delete tax. Tax cannot be deleted when in use.": "Unable to delete tax. Tax cannot be deleted when in use.",
"Unable to save tax.": "Unable to save tax.",
"Tax saved": "Tax saved",
"File": "Fichier",
"send": "send",
...
...
modules/base_products/languages/fr.locale
View file @
a51871c2
...
...
@@ -28,6 +28,8 @@
"Rates": "Taux",
"New tax rate": "Nouveau taux",
"Unable to delete tax. Tax cannot be deleted when in use.": "Impossible de supprimer la taxe. Une taxe ne peut pas être supprimée lorsqu'elle est utilisée.",
"Unable to save tax.": "Impossible d'enregistrer la taxe.",
"Tax saved": "Taxe enregistrée",
"send": "envoyer",
"File": "Fichier",
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment