Skip to content

Commit

Permalink
Merge pull request #671 from boxwise/feat/forward-assort-products-to-v2
Browse files Browse the repository at this point in the history
Add Tab In Manage Product And Restrict Editing For Standard ASSORT Products
  • Loading branch information
HaGuesto authored Feb 24, 2025
2 parents 0aa3752 + cf2cc6d commit 6192c88
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
9 changes: 6 additions & 3 deletions include/products.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
$ajax = checkajax();
if (!$ajax) {
initlist();

listsetting('haspagemenu', true);
addpagemenu('base_products', strtoupper((string) $_SESSION['camp']['name']).' PRODUCTS', ['active' => true, 'link' => '?action=products', 'testid' => 'products']);
addpagemenu('assort_products', 'ASSORT STANDARD PRODUCTS', ['link' => $settings['v2_base_url'].'/bases/'.$_SESSION['camp']['id'].'/products']);
$cmsmain->assign('title', 'Products');
listsetting('search', ['name', 'g.label', 'products.comments']);

Expand All @@ -17,7 +19,8 @@
g.label AS gender,
CONCAT(products.value," '.$_SESSION['camp']['currencyname'].'") AS drops,
COALESCE(SUM(s.items),0) AS items,
IF(SUM(s.items),1,0) AS preventdelete
IF(SUM(s.items) OR products.standard_product_id IS NOT NULL, 1, 0) AS preventdelete,
IF(products.standard_product_id,1,0) AS preventedit
FROM products
LEFT OUTER JOIN genders AS g ON g.id = products.gender_id
LEFT OUTER JOIN sizegroup AS sg ON sg.id = products.sizegroup_id
Expand All @@ -35,7 +38,7 @@
$count += $d['items'];
}

addcolumn('text', 'Product name', 'name');
addcolumn('text_cond_icon', 'Product name', 'name');
addcolumn('text', 'Gender', 'gender');
addcolumn('text', 'Sizegroup', 'sizegroup');
if ($count) {
Expand Down
7 changes: 5 additions & 2 deletions include/products_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

if ($_POST) {
$handler = new formHandler($table);

// Trelo ref https://trello.com/c/NRHVvf2u
$product = db_row('SELECT standard_product_id FROM products WHERE id = :id', ['id' => $_POST['id']]);
if (!empty($product['standard_product_id'])) {
throw new Exception('This product is a STANDARD ASSORT PRODUCT and cannot be edited');
}
$savekeys = ['name', 'gender_id', 'value', 'category_id', 'maxperadult', 'maxperchild', 'sizegroup_id', 'camp_id', 'comments', 'stockincontainer'];
$id = $handler->savePost($savekeys);

redirect('?action='.$_POST['_origin']);
}

Expand Down
10 changes: 10 additions & 0 deletions templates/cms_list_text_cond_icon.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{if $listdata[$column['field']]['breakall']}<span class="breakall">{/if}
{$row[$column['field']]|strip_tags:false|truncate}
{if !empty($row['standard_product_id'])}
<span class="list-toggle-value hide">{$row['standard_product_id']}</span>
<span class="list-toggle inside-list-start-operation stay active">
<span class="fa fa-circle-o"></span>
<span class="fa fa-check-circle active" title="This product is part of the ASSORT standard"></span>
</span>
{/if}
{if $listdata[$column['field']]['breakall']}</span>{/if}

0 comments on commit 6192c88

Please sign in to comment.