I'm making a module in Prestashop 1.6 where the admin will be able to set quotas dive groups and categories. Tables below:
CREATE TABLE quota
(
id_quota INT PRIMARY KEY AUTO_INCREMENT,
id_group INT NOT NULL,
max_amount_per_order INT NOT NULL,
max_amount_per_month INT NOT NULL
);
AND
CREATE TABLE quota_category
(
id_quota_category BIGINT PRIMARY KEY AUTO_INCREMENT,
id_category INT NOT NULL,
id_quota INT NOT NULL,
);
As you can see it is one record in the first table and many in de second.
Do to the form for this I use a select for the group and a treeview for the categories, all using the form help, I'm not using .tpl
files.
array(
'type' => 'select',
'label' => $this->l('Group'),
'name' => 'id_group',
'options' => array(
'query' => GroupCore::getGroups($this->context->language->id),
'id' => 'id_group',
'name' => 'name',
),
'required' => true
),
array(
'type' => 'categories',
'label' => $this->l('Category'),
'name' => 'id_category',
'tree' => [
'selected_categories' => [1,2,4],
'disabled_categories' => null,
'use_search' => true,
'use_checkbox' => true,
'id' => 'id_category_tree',
],
'required' => true
),
The form is rendering as intended, my problem is that I don't know now how I can treat the form to insert in both tables.
Can you give some help? I was trying to find similar cases but I couldn't find so far.
Thanks for any help
答案 0 :(得分:1)
以下是我如何解决它。在Sub MergeFiles_Click()
Dim strSourcePath As String
Dim strDestPath As String
Dim strFile As String
Dim strData As String
Dim x As Variant
Dim Cnt As Long
Dim r As Long
Dim c As Long
Dim inputRow As Long
Application.ScreenUpdating = False
strSourcePath = Sheet1.Range("G2").Value
If Right(strSourcePath, 1) <> "\" Then strSourcePath = strSourcePath & "\"
strFile = Dir(strSourcePath & "*.csv")
Do While Len(strFile) > 0
Cnt = Cnt + 1
If Cnt = 1 Then
r = 6
Else
r = Cells(Rows.Count, "A").End(xlUp).Row + 1
End If
Open strSourcePath & strFile For Input As #1
inputRow = 0
Do Until EOF(1)
Line Input #1, strData
'Maintain a count of how many rows have been read
inputRow = inputRow + 1
'Only process rows if this is the first file, or if we have
'already passed the 12th row
If Cnt = 1 Or inputRow > 12 Then
x = Split(strData, ",")
For c = 0 To UBound(x)
Cells(r, c + 1).Value = Trim(x(c))
Next c
r = r + 1
End If
Loop
Close #1
strFile = Dir
Loop
Application.ScreenUpdating = True
If Cnt = 0 Then _
MsgBox "No CSV files were found...", vbExclamation
End Sub
和processSave()
上调用add
,并且它返回的对象始终具有update
属性。在表单中定义树视图时,您可以为其设置名称。只需使用Tool :: getValue(&#39; name_of_the_treeview&#39;)。
id