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.
 
 
 
 
 
 

156 lines
4.1 KiB

::use 'contractadmin/design.mtt'::
<h3>::_("Products")::</h3>
<div>
<p>
$$insert(::_("New product")::,/product/insert/::c.id::)
<a href="/product/import/::c.id::" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-list-alt"></span> ::_("Import from Excel/CSV")::</a>
::if !c._amap.hasTaxonomy()::
<a ::cond c.type==1:: href="/product/categorize/::c.id::" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-tag"></span> ::_("Categories")::</a>
::end::
</p>
</div>
<script>
//enable checked products
var enableProducts = function(){
var ids = _.getCheckboxesId('form.products');
if(ids.length==0){
alert("::_("You need to select at least one product to perform this action")::");
}else{
var l = document.location;
l.href = l.protocol +"//"+ l.host + l.pathname + "?enable="+ ids.join("|");
}
};
//disable checked products
var disableProducts = function(){
var ids = _.getCheckboxesId('form.products');
if(ids.length==0){
alert("::_("You need to select at least one product to perform this action")::");
}else{
var l = document.location;
l.href = l.protocol +"//"+ l.host + l.pathname + "?disable="+ ids.join("|");
}
};
//check input when click row
/*var clickRow = function(x){
x.children[0].children[0].checked = !x.children[0].children[0].checked;
}*/
//check all
var check = function(){
var inputs = document.querySelectorAll('form.products input');
var value = inputs[0].checked==true;
for ( i of inputs ) {
i.checked = !value;
}
}
</script>
<form method="GET" class="products">
<table class="table table-striped table-hover">
<tr>
<th></th>
<th></th>
<th>::_("Product ID||id or reference of a product")::</th>
<th>::_("Name")::</th>
<th>::_("Price")::</th>
<th></th>
::if c.hasStockManagement()::
<th>::_("Stock")::</th>
::end::
<th></th>
</tr>
::foreach p c.getProducts(false)::
::if p.active==false::
::set opacity=0.4::
::else::
::set opacity=1::
::end::
<tr style="opacity: ::opacity::" onclick="/*clickRow(this)*/">
<td>
<input type="checkbox" name="checkbox" value="::p.id::" />
</td>
<td>
<img src="::p.getImage()::" style="width:64px;height:64px;" />
</td>
<td class="ref">$$nullSafe(::p.ref::)</td>
<td>
<b>::p.name::</b>
::if p._unitType!=null && p.qt!=null::
::p.qt::&nbsp;::unit(p._unitType,false)::
::end::
::if !c._amap.hasTaxonomy()::
<div>
::foreach c p.getCategories()::
<span class='tag' style='background-color: ::c.getColor()::;'>::c.name::</span>
::end::
</div>
::else::
<div class="detail">
::p.getFullCategorization().join(" / ")::
</div>
::end::
<div>
::if p.organic ::<img src="/img/AB.png" style="display:inline-block"/>::end::
::if p.variablePrice ::<img src="/img/weight.png" style="display:inline-block"/>::end::
</div>
</td>
<td>::formatNum(p.price)::&nbsp;::currency()::</td>
<td>
::if c.hasStockManagement() ::
::if p.stock==null::
-
::else::
::if p.stock <= 10::
<span style="color:red;font-weight:bold;">
::p.stock::
</span>
::else::
::p.stock::
::end::
::end::
::end::
</td>
<td>
<div class="btn-group" role="group">
$$edit(::_("Edit")::,/product/edit/::p.id::)
<a href="/product/addImage/::p.id::" class="btn btn-default btn-sm"> <span class="glyphicon glyphicon-picture"></span> ::_("Picture")::</a>
$$delete(::_("Del.")::,/product/delete/::p.id::?token=::token::)
</div>
</td>
</tr>
::end::
</table>
</form>
<p>
<div class="btn-group" role="group">
<a onclick="check();" class="btn btn-default btn-sm btn-noAntiDoubleClick"> ::_("Check all")::</a>
</div>
<div class="btn-group" role="group">
<a class="btn btn-default btn-sm" onclick="enableProducts()"><span class="glyphicon glyphicon-check"></span> ::_("Enable")::</a>
<a class="btn btn-default btn-sm" onclick="disableProducts()"><span class="glyphicon glyphicon-unchecked"></span> ::_("Disable")::</a>
</div>
</p>
::end::