You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
4.1 KiB

  1. ::use 'contractadmin/design.mtt'::
  2. <h3>::_("Products")::</h3>
  3. <div>
  4. <p>
  5. $$insert(::_("New product")::,/product/insert/::c.id::)
  6. <a href="/product/import/::c.id::" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-list-alt"></span> ::_("Import from Excel/CSV")::</a>
  7. ::if !c._amap.hasTaxonomy()::
  8. <a ::cond c.type==1:: href="/product/categorize/::c.id::" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-tag"></span> ::_("Categories")::</a>
  9. ::end::
  10. </p>
  11. </div>
  12. <script>
  13. //enable checked products
  14. var enableProducts = function(){
  15. var ids = _.getCheckboxesId('form.products');
  16. if(ids.length==0){
  17. alert("::_("You need to select at least one product to perform this action")::");
  18. }else{
  19. var l = document.location;
  20. l.href = l.protocol +"//"+ l.host + l.pathname + "?enable="+ ids.join("|");
  21. }
  22. };
  23. //disable checked products
  24. var disableProducts = function(){
  25. var ids = _.getCheckboxesId('form.products');
  26. if(ids.length==0){
  27. alert("::_("You need to select at least one product to perform this action")::");
  28. }else{
  29. var l = document.location;
  30. l.href = l.protocol +"//"+ l.host + l.pathname + "?disable="+ ids.join("|");
  31. }
  32. };
  33. //check input when click row
  34. /*var clickRow = function(x){
  35. x.children[0].children[0].checked = !x.children[0].children[0].checked;
  36. }*/
  37. //check all
  38. var check = function(){
  39. var inputs = document.querySelectorAll('form.products input');
  40. var value = inputs[0].checked==true;
  41. for ( i of inputs ) {
  42. i.checked = !value;
  43. }
  44. }
  45. </script>
  46. <form method="GET" class="products">
  47. <table class="table table-striped table-hover">
  48. <tr>
  49. <th></th>
  50. <th></th>
  51. <th>::_("Product ID||id or reference of a product")::</th>
  52. <th>::_("Name")::</th>
  53. <th>::_("Price")::</th>
  54. <th></th>
  55. ::if c.hasStockManagement()::
  56. <th>::_("Stock")::</th>
  57. ::end::
  58. <th></th>
  59. </tr>
  60. ::foreach p c.getProducts(false)::
  61. ::if p.active==false::
  62. ::set opacity=0.4::
  63. ::else::
  64. ::set opacity=1::
  65. ::end::
  66. <tr style="opacity: ::opacity::" onclick="/*clickRow(this)*/">
  67. <td>
  68. <input type="checkbox" name="checkbox" value="::p.id::" />
  69. </td>
  70. <td>
  71. <img src="::p.getImage()::" style="width:64px;height:64px;" />
  72. </td>
  73. <td class="ref">$$nullSafe(::p.ref::)</td>
  74. <td>
  75. <b>::p.name::</b>
  76. ::if p._unitType!=null && p.qt!=null::
  77. ::p.qt::&nbsp;::unit(p._unitType,false)::
  78. ::end::
  79. ::if !c._amap.hasTaxonomy()::
  80. <div>
  81. ::foreach c p.getCategories()::
  82. <span class='tag' style='background-color: ::c.getColor()::;'>::c.name::</span>
  83. ::end::
  84. </div>
  85. ::else::
  86. <div class="detail">
  87. ::p.getFullCategorization().join(" / ")::
  88. </div>
  89. ::end::
  90. <div>
  91. ::if p.organic ::<img src="/img/AB.png" style="display:inline-block"/>::end::
  92. ::if p.variablePrice ::<img src="/img/weight.png" style="display:inline-block"/>::end::
  93. </div>
  94. </td>
  95. <td>::formatNum(p.price)::&nbsp;::currency()::</td>
  96. <td>
  97. ::if c.hasStockManagement() ::
  98. ::if p.stock==null::
  99. -
  100. ::else::
  101. ::if p.stock <= 10::
  102. <span style="color:red;font-weight:bold;">
  103. ::p.stock::
  104. </span>
  105. ::else::
  106. ::p.stock::
  107. ::end::
  108. ::end::
  109. ::end::
  110. </td>
  111. <td>
  112. <div class="btn-group" role="group">
  113. $$edit(::_("Edit")::,/product/edit/::p.id::)
  114. <a href="/product/addImage/::p.id::" class="btn btn-default btn-sm"> <span class="glyphicon glyphicon-picture"></span> ::_("Picture")::</a>
  115. $$delete(::_("Del.")::,/product/delete/::p.id::?token=::token::)
  116. </div>
  117. </td>
  118. </tr>
  119. ::end::
  120. </table>
  121. </form>
  122. <p>
  123. <div class="btn-group" role="group">
  124. <a onclick="check();" class="btn btn-default btn-sm btn-noAntiDoubleClick"> ::_("Check all")::</a>
  125. </div>
  126. <div class="btn-group" role="group">
  127. <a class="btn btn-default btn-sm" onclick="enableProducts()"><span class="glyphicon glyphicon-check"></span> ::_("Enable")::</a>
  128. <a class="btn btn-default btn-sm" onclick="disableProducts()"><span class="glyphicon glyphicon-unchecked"></span> ::_("Disable")::</a>
  129. </div>
  130. </p>
  131. ::end::