Commit 94a75299 authored by Tibor Katelbach's avatar Tibor Katelbach
Browse files

step Operator

parent aac4464e
<?php
//check show btn use cases
// role is financer or operater
if( Form::canFormAccess( ['roles'=>["Financeur","opérateur"] ]))
{
if( isset($form['id']) )
{ ?>
<table class="table table-bordered table-hover directoryTable" >
<tbody class="directoryLines">
<tr>
<td colspan='2' ><h3 style="color:#16A9B1">Intention Opérateur</h3></td>
</tr>
<?php
$str = "";
$selectedOperator = false;
if(isset($answer["links"]["operators"]))
{
$communityLinks = Element::getCommunityByTypeAndId($this->costum["contextType"],$this->costum["contextId"]);
$persons = Link::groupFindByType( Person::COLLECTION,$communityLinks,["name","links"] );
$organizations = Link::groupFindByType( Organization::COLLECTION,$communityLinks,["name","links"] );
$financers = array_merge( $persons, $organizations );
$orgs = [];
if( !empty($or["links"]["memberOf"][$this->costum["contextId"]]["roles"]) ) {
foreach ($financers as $id => $or) {
$roles = $or["links"]["memberOf"][$this->costum["contextId"]]["roles"];
if( isset($this->costum["form"]["params"]["financement"]["limitRoles"]) && !empty($roles))
{
foreach ($roles as $i => $r) {
if( in_array($r, $this->costum["form"]["params"]["financement"]["limitRoles"]) )
$orgs[$id] = $or["name"];
}
}
}
}
// var_dump($orgs);exit;
foreach ($answer["links"]["operators"] as $oid => $state) {
if($state != "0")
{
$selectedOperator = true;
$str = '<tr>'.
'<td>Opérateur</td>'.
'<td>'.$oid.'</td>'.
'<td><span class="label label-success">Validé</span></td>'.
'</tr>';
}
else if( !$selectedOperator )
{
//if role financeurs
$str .= '<tr>'.
'<td>Opérateur Candidat</td>'.
'<td>'.$oid.'</td>'.
'<td><span class="label label-success"><a href="javascript:;" class="validateOperator" data-id="'.$oid.'">à Valider</a></span></td>'.
'</tr>';
}
}
}
echo $str;
//if role operateurs
if(!$selectedOperator){
?>
<tr>
<td colspan='2' class="text-center" >
<a href="javascript:;" data-oid="<?php echo Yii::app()->session["userId"] ?>" class="intentOperator btn btn-primary">Opérateur : Demander de prendre en charge</a>
</td>
</tr>
<?php
}
//if role financeur
if(!$selectedOperator){
?>
<tr>
<td colspan='2' class="text-center" >
<a href="javascript:;" data-oid="<?php echo Yii::app()->session["userId"] ?>" class="validateOperator btn btn-danger">Financeur : Veuillez étudier ce dossier</a>
</td>
</tr>
<?php }?>
</tbody>
</table>
<?php
} ?>
<script type="text/javascript">
$(document).ready(function() {
mylog.log("render","modules/survey/views/tpls/forms/costum/deal/stepOperateur.php");
var today = new Date();
today = today.getDate() + '/' + (today.getMonth()+1) + '/' + today.getFullYear();
$('.validateOperator').off().on("click", function() {
var oid = $(this).data("id");
ctxTpl = {
id : "<?php echo $answer['_id'] ?>",
collection : "answers",
path : "links.operators."+oid,
value : {
date : today,
user : userId
}
};
$(this).fadeOut();
dataHelper.path2Value( ctxTpl, function(params) {
urlCtrl.loadByHash(location.hash);
} );
});
$('.intentOperator').off().on("click", function() {
var oid = $(this).data("oid");
ctxTpl = {
id : "<?php echo $answer['_id'] ?>",
collection : "answers",
path : "links.operators."+oid,
value : "0"
};
dataHelper.path2Value( ctxTpl, function(params) {
urlCtrl.loadByHash(location.hash);
} );
});
});
</script>
<?php } else {?>
<div class="col-xs-12">
Cette étape sera validé par un opérateur et les financeurs.
</div>
<?php } ?>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment