Files
crmPRO/templates/projects/toreview-tasks.php
2024-11-10 11:11:35 +01:00

134 lines
6.1 KiB
PHP

<? global $user;?>
<? if ( $this -> toreview_tasks and count( $this -> toreview_tasks ) ):?>
<div class="task-group">
<div class="title">
Zadania do sprawdzenia
</div>
<div class="dragbleList toreview-tasks">
<ul class="tasks-list sortable-list">
<? if ( is_array( $this -> toreview_tasks ) ):?>
<? foreach ( $this -> toreview_tasks as $task ):?>
<? $task_open = \factory\Projects::is_task_open( $task['id'], $user['id'] );?>
<li class="sortable-item task <? if ( $task_open ):?>open<? endif;?> <? if ( $task['date_end'] and $task['date_end'] <= date( 'Y-m-d' ) and !$task['status'] ):?>delayed<? endif;?>" task-id="<?= $task['id'];?>" id="task-<?= $task['id'];?>">
<div class="manage-menu">
<span class="context-menu" data-container-id="task-<?= $task['id'];?>-menu"></span>
<div class="context-menu-container" id="task-<?= $task['id'];?>-menu">
<ul>
<li>
<a href="/projects/task_edit/id=<?= $task['id'];?>" class="task-edit">
Edytuj
</a>
</li>
<li>
<a href="#" class="task-remove" task-id="<?= $task['id'];?>">
Usuń zadanie
</a>
</li>
<li>
<a href="#" class="task-remove-all" task-id="<?= $task['id'];?>">
Usuń zadania i zadania powiązane
</a>
</li>
</ul>
</div>
</div>
<div class="dates <? if ( $task['date_end'] ):?>set<? endif;?>">
<? if ( $task['date_end'] ):?>
<?= $task['date_end'];?>
<? else:?>
-
<? endif;?>
</div>
<div class="flex flex-ac">
<? if ( !$task_open ):?>
<a href="#" class="task-start" task-id="<?= $task['id'];?>">
<i class="fa fa-play"></i>
</a>
<? else:?>
<a href="#" class="task-end" task-id="<?= $task['id'];?>">
<i class="fa fa-stop"></i>
</a>
<? endif;?>
<div class="time">
<?= sprintf( "%02d%s%02d%s%02d", floor( $task['total_time'] / 3600 ), ':', ( $task['total_time'] / 60) % 60, ':', $task['total_time'] % 60 );?>
</div>
<div class="status">
<select name="task-status" class="task-status" task_id="<?= $task['id'];?>">
<option value="0" <? if ( $task['status'] == 0 ):?>selected="selected"<? endif;?>>nowe</option>
<option value="1" <? if ( $task['status'] == 1 ):?>selected="selected"<? endif;?>>do sprawdzenia</option>
<? if ( $user['id'] == 1 ):?>
<option value="2" <? if ( $task['status'] == 2 ):?>selected="selected"<? endif;?>>zamknięte</option>
<? endif;?>
</select>
</div>
<div class="name">
<div class="top">
<? if ( $open_subtasks = \factory\Projects::count_open_subtasks( $task['id'] ) ):?>
<a href="#" class="open_subtasks_count" onclick="return false;" task-id="<?= $task['id'];?>">
<?= $open_subtasks;?>
</a>
<? endif;?>
<? if ( $task['text'] ):?>
<a href="#" class="task-details" task-id="<?= $task['id'];?>">
<i class="fa fa-info"></i>
</a>
<? endif;?>
<? if ( $task['client_id'] ):?>
<span class="client_info" task-id="<?= $task['id'];?>"><?= \factory\Crm::get_client_name( (int)$task['client_id'] );?></span>
<? endif;?>
<? if ( $task['pay_rate'] and $this -> user['id'] == 1 ):?>
<span class="pay-rate">stawka: <strong><?= $task['pay_rate'];?> zł</strong></span>
<? endif;?>
</div>
<div class="bottom">
<span class="task-details" task-id="<?= $task['id'];?>">
<?= $task['name'];?><? if ( $task['actions'] and count( $task['actions'] ) ):?> <? $count = 0; foreach ( $task['actions'] as $action ) if ( $action['status'] == null ) $count++; if ( $count ) echo '(' . $count . ')';?><? endif;?>
</span>
</div>
</div>
</div>
<div class="users">
<? if ( is_array( $task['users'] ) ): foreach ( $task['users'] as $user_tmp_id ):?>
<?
$user_tmp = \factory\Users::user_details( $user_tmp_id );
echo '<div class="user" style="background: ' . $user_tmp['color'] . '">' . $user_tmp['name'][0] . $user_tmp['surname'][0] . '</div>';
?>
<? endforeach; endif;?>
</div>
<script type="text/javascript">
$( function()
{
$(document).ready(function(){
var tableContextMenu = new ContextMenu("task-<?= $task['id'];?>-menu", menuItemClickListener);
});
});
</script>
</li>
<? endforeach;?>
<? endif;?>
</ul>
</div>
</div>
<? endif;?>
<? if ( $user['id'] == 1 ):?>
<script type="text/javascript">
$( '.toreview-tasks .sortable-list' ).sortable({
stop : function(event, ui) {
var tasks_order = $( this ).sortable('toArray', { attribute: 'task-id' } );
$.ajax({
type: 'POST',
cache: false,
url: '/projects/tasks_order_save/',
data: {
tasks_order: tasks_order
},
beforeSend: function() {},
success: function( response ) {
}
});
}
});
</script>
<? endif;?>