<div class="padding">

    <div class="row">
        <div class="col-xs-6"><h6>{%= __("User") %}</h6></div>
        <div class="col-xs-2"><h6>{%= __("Can Read") %}</h6></div>
        <div class="col-xs-2"><h6>{%= __("Can Write") %}</h6></div>
        <div class="col-xs-2"><h6>{%= __("Can Share") %}</h6></div>
    </div>

	<div class="row shared-user" data-everyone=1>
        <div class="col-xs-6 share-all" style="height: 30px;"><b>{{ __("Everyone") }}</b></div>
        <div class="col-xs-2"><input type="checkbox" name="read"
            {% if(cint(everyone.read)) { %}checked{% } %} class="edit-share"></div>
        <div class="col-xs-2"><input type="checkbox" name="write"
            {% if(cint(everyone.write)) { %}checked{% } %} class="edit-share"{% if (!frm.perm[0].write){ %} disabled="disabled"{% } %}></div>
        <div class="col-xs-2"><input type="checkbox" name="share"
            {% if(cint(everyone.share)) { %}checked{% } %} class="edit-share"></div>
	</div>

    {% for (var i=0, l=shared.length; i < l; i++) {
        var s = shared[i]; %}
	    {% if(s && !s.everyone) { %}
	    <div class="row shared-user" data-user="{%= s.user %}" data-name="{%= s.name %}">
	        <div class="col-xs-6">{%= s.user %}</div>
	        <div class="col-xs-2"><input type="checkbox" name="read"
	            {% if(cint(s.read)) { %}checked{% } %} class="edit-share"></div>
	        <div class="col-xs-2"><input type="checkbox" name="write"
	            {% if(cint(s.write)) { %}checked{% } %} class="edit-share"{% if (!frm.perm[0].write){ %} disabled="disabled"{% } %}></div>
	        <div class="col-xs-2"><input type="checkbox" name="share"
	            {% if(cint(s.share)) { %}checked{% } %} class="edit-share"></div>
	    </div>
	    {% } %}
    {% } %}

    {% if(frappe.model.can_share(null, frm)) { %}
    <hr>

    <div class="row">
        <div class="col-xs-6"><h6>{%= __("Share this document with") %}</h6></div>
        <div class="col-xs-2"><h6>{%= __("Can Read") %}</h6></div>
        <div class="col-xs-2"><h6>{%= __("Can Write") %}</h6></div>
        <div class="col-xs-2"><h6>{%= __("Can Share") %}</h6></div>
    </div>

    <div class="row">
        <div class="col-xs-6 input-wrapper-add-share"></div>
        <div class="col-xs-2"><input type="checkbox" class="add-share-read" name="read"></div>
        <div class="col-xs-2"><input type="checkbox" class="add-share-write" name="write" {% if (!frm.perm[0].write){ %} disabled="disabled"{% } %}></div>
        <div class="col-xs-2"><input type="checkbox" class="add-share-share" name="share"></div>
    </div>
    <p>
        <button class="btn btn-primary btn-add-share">{{ __("Add") }}</button>
    </p>
	{% endif %}
</div>