Commit ee45e6cd authored by Raph El's avatar Raph El
Browse files

Mode PDF

parent 6bd29e78
......@@ -6,32 +6,37 @@ else if(!empty($answer) && isset($answer["answers"][$kunik]) && $answer["answers
$value = "checked";
$inpClass = "";
if($saveOneByOne)
$inpClass = " saveOneByOne";
if($mode == "r"){ ?>
if($mode == "r" || $mode == "pdf"){ ?>
<div class="col-xs-12" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></label>
<?php
echo @$form["inputs"][$key]["placeholder"]." : ".(!empty($value) ? "Yes" : "No");
?>
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></label><br/>
<?php echo @$form["inputs"][$key]["placeholder"]." : ".(!empty($value) ? "Yes" : "No"); ?>
</div>
<?php
}else{
?>
<div class="form-check">
<label class="form-check-label" for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label>
<label class="form-check-label" for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label>
<br/>
<input type="checkbox" class="form-check-input <?php echo $inpClass ?>" id="<?php echo $kunik ?>" data-form='<?php echo $form["id"] ?>' <?php echo $value ?> > <?php echo @$form["inputs"][$key]["placeholder"]?>
<?php if(!empty($info)){ ?>
<small id="<?php echo $key ?>Help" class="form-text text-muted"><?php echo $info ?></small>
<?php } ?>
</div>
<script type="text/javascript">
<?php } ?>
<?php if($mode != "pdf"){ ?>
<script type="text/javascript">
jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/checkbox.php");
});
</script>
</script>
<?php } ?>
\ No newline at end of file
<?php
//check show btn use cases
// role is financer or operater
if( $mode != "pdf" ){
if(Form::canFormAccess( ['roles'=>["Financeur","Opérateur"] ]))
{
if( isset($form['id']) )
{ ?>
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' ><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>">Intention Opérateur</h4></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"];
}
<table class="table table-bordered table-hover directoryTable" >
<tbody class="directoryLines">
<tr>
<td colspan='2' ><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>">Intention Opérateur</h4></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;
// 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>';
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
}
}
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
}} else { ?>
<div class="col-xs-12 text-center margin-top-50 well">
<?php if(@$answer["step"] && $answer["step"]=="deal1"){ ?>
<span style="font-size: 22px;font-weight: 800;">Vous avez soumis votre dossier pour qu'un opérateur se positionne dessus.<br/>Il est en cours de validation.
Cette étape sera validé par un opérateur et les financeurs.</span>
<?php }else{ ?>
<span class="text-center" style="font-size: 22px;font-weight: 800;">
Une fois votre dossier estimé rempli, vous pouvez le valider afin qu'il soit mis sous étude des opérateurs et des financeurs<br/><br/>
<a href="javascript:;" class="validateForSubmit btn btn-success">
Soumettre votre dossier
</a>
</span>
<?php } ?>
</div>
<?php } ?>
<script type="text/javascript">
//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
}
} else { ?>
<div class="col-xs-12 text-center margin-top-50 well">
<?php if(@$answer["step"] && $answer["step"]=="deal1"){ ?>
<span style="font-size: 22px;font-weight: 800;">Vous avez soumis votre dossier pour qu'un opérateur se positionne dessus.<br/>Il est en cours de validation.
Cette étape sera validé par un opérateur et les financeurs.</span>
<?php }else{ ?>
<span class="text-center" style="font-size: 22px;font-weight: 800;">
Une fois votre dossier estimé rempli, vous pouvez le valider afin qu'il soit mis sous étude des opérateurs et des financeurs<br/><br/>
<a href="javascript:;" class="validateForSubmit btn btn-success">
Soumettre votre dossier
</a>
</span>
<?php } ?>
</div>
<?php
} ?>
<script type="text/javascript">
$(document).ready(function() {
$(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();
mylog.log("save step save",ctxTpl);
dataHelper.path2Value( ctxTpl, function(params) {
ctxTpl = {
id : "<?php echo $answer['_id'] ?>",
collection : "answers",
path : "step",
value : "deal3" //pourrait etre un parametre element.costum.form.stepOperateur : deal3
};
mylog.log("save step save",ctxTpl);
dataHelper.path2Value( ctxTpl, function(params) {
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();
mylog.log("save step save",ctxTpl);
dataHelper.path2Value( ctxTpl, function(params) {
ctxTpl = {
id : "<?php echo $answer['_id'] ?>",
collection : "answers",
path : "step",
value : "deal3" //pourrait etre un parametre element.costum.form.stepOperateur : deal3
};
mylog.log("save step save",ctxTpl);
dataHelper.path2Value( ctxTpl, function(params) {
urlCtrl.loadByHash(location.hash);
} );
} );
});
$('.validateForSubmit').off().on("click", function() {
ctxTpl = {
id : "<?php echo $answer['_id'] ?>",
collection : "answers",
path : "step",
value : "deal1"
};
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);
} );
} );
});
$('.validateForSubmit').off().on("click", function() {
ctxTpl = {
id : "<?php echo $answer['_id'] ?>",
collection : "answers",
path : "step",
value : "deal1"
};
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 } ?>
});
</script>
......@@ -5,7 +5,7 @@ if(!empty($answer) && isset($answer["answers"][$form["id"]][$kunik]))
else if(!empty($answer) && isset($answer["answers"][$kunik]))
$value = $answer["answers"][$kunik];
if($mode == "r"){ ?>
if($mode == "r" || $mode == "pdf"){ ?>
<div class="col-xs-12" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></label>
<?php
......
......@@ -2,7 +2,7 @@
$debug = false;
$editBtnL = (Yii::app()->session["userId"] == $answer["user"]) ? " <a href='javascript:;' data-id='".$answer["_id"]."' data-collection='".Form::ANSWER_COLLECTION."' data-path='".$answerPath."' class='add".$kunik." btn btn-default'><i class='fa fa-plus'></i> Ajouter une ligne </a>" : "";
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".$this->costum["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl edit".$kunik."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$editParamsBtn = ($canEditForm) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".$this->costum["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl edit".$kunik."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$paramsData = [
"group" => [
......@@ -109,7 +109,7 @@ echo $this->renderPartial("survey.views.tpls.forms.cplx.budgetTable",
<?php }
if($mode != "r"){
if($mode != "r" && $mode != "pdf"){
?>
<script type="text/javascript">
......
<?php
$colspanplus = (($mode == "r") ? 0 : 2);
$styleT = ( ($mode == "pdf") ? " border : 1px solid black ;" : "");
//var_dump($styleT);
$colspanplus = (($mode == "r" || $mode == "pdf") ? 0 : 2);
?>
<div class="form-group">
<?php
if($mode == "r"){ ?>
if($mode == "r" || $mode == "pdf"){ ?>
<label ><h4 style="color:<?php echo (!empty($titleColor) ? $titleColor : "black" ); ?>"><?php echo $label ; ?></h4></label>
<?php echo $info ?>
<?php
......@@ -15,7 +16,8 @@ $colspanplus = (($mode == "r") ? 0 : 2);
<?php echo $info ?>
<?php
} ?>
<table class="table table-bordered table-hover directoryTable" id="<?php echo $kunik?>">
<table class="table table-bordered table-hover directoryTable" id="<?php echo $kunik ; ?>"
>
<thead>
<?php
......@@ -28,7 +30,7 @@ $colspanplus = (($mode == "r") ? 0 : 2);
} ?>
<?php
if($mode != "r"){ ?>
if($mode != "r" && $mode != "pdf"){ ?>
<th></th>
<?php } ?>
</tr>
......@@ -70,7 +72,7 @@ $colspanplus = (($mode == "r") ? 0 : 2);
echo "<tr id='".$kunik.$q."' class='".$kunik."Line'>";
echo $tds;
if($mode != "r"){
if($mode != "r" && $mode != "pdf"){
?>
<td>
<?php
......@@ -120,7 +122,7 @@ if($total > 0){
echo "<tr class='bold'>";
echo "<td colspan=".(count( $paramsData["amounts"] )+2)." style='text-align:right'> TOTAL : </td>";
if($mode != "r")
if($mode != "r" && $mode != "pdf")
echo "<td colspan='".$colspanplus."''>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
else
echo "<td>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
......
......@@ -34,7 +34,7 @@
$editBtnL = (Yii::app()->session["userId"] == $answer["user"]) ? " <a href='javascript:;' data-id='".$answer["_id"]."' data-collection='".Form::ANSWER_COLLECTION."' data-path='".$answerPath."' class='add".$kunik." btn btn-default'><i class='fa fa-plus'></i> Ajouter une ligne </a>" : "";
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".$this->costum["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl edit".$kunik."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$editParamsBtn = ($canEditForm) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".$this->costum["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl edit".$kunik."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
?>
<thead>
<tr>
......
......@@ -407,7 +407,7 @@ if( isset($this->costum["form"]["params"]["financement"]["tpl"])){
// $this->renderPartial( "costum.views.".$this->costum["form"]["params"]["financement"]["tpl"]);
}
?>
<?php if($mode != "pdf"){ ?>
<script type="text/javascript">
if(typeof costum.lists == "undefined")
costum.lists = {};
......@@ -649,6 +649,7 @@ $(document).ready(function() {
});
});
</script>
<?php } ?>
<?php } else {
//echo "<h4 class='text-red'>CALENDAR works with existing answers</h4>";
} ?>
\ No newline at end of file
......@@ -9,7 +9,7 @@ $paramsData = [ "options" => [ ] ];
if( isset($this->costum["form"]["params"][$key]) )
$paramsData = $this->costum["form"]["params"][$key];
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".$this->costum["contextType"]."' data-path='costum.form.params.".$key."' class='previewTpl edit".$key."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$editParamsBtn = ($canEditForm) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".$this->costum["contextType"]."' data-path='costum.form.params.".$key."' class='previewTpl edit".$key."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
?>
<div class="form-group">
......
<?php
if( Form::canFormAccess( ['roles'=>["Financeur"] ]) )
{
if( isset($form['id']) )
if( $mode != "pdf" ){
if( Form::canFormAccess( ['roles'=>["Financeur"] ]) )
{
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".$this->costum["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl edit".$kunik."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
if( isset($form['id']) )
{
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".$this->costum["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl edit".$kunik."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$paramsData = [
"limitRoles" =>["Financeur"]
];
$paramsData = [
"limitRoles" =>["Financeur"]
];
if( isset($this->costum["form"]["params"][$kunik]) ) {
if( isset($this->costum["form"]["params"][$kunik]["limitRoles"]) )
$paramsData["financersList"] = $this->costum["form"]["params"][$kunik]["limitRoles"];
}
if( isset($this->costum["form"]["params"][$kunik]) ) {
if( isset($this->costum["form"]["params"][$kunik]["limitRoles"]) )
$paramsData["financersList"] = $this->costum["form"]["params"][$kunik]["limitRoles"];
}
?>
?>
<div id="copyEquilibreBudgetaire"></div>
<div id="copyEquilibreBudgetaire"></div>
<table class="table table-bordered table-hover directoryTable" >
<tbody class="directoryLines">
<tr>
<td colspan='2' ><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>">Validation</h4>
</td>
</tr>
<?php
if( isset( $answer["validation"][ $form['id'] ] ) )
{ ?>
<tr>
<td colspan='2' align="center">
<button id="generateCopil2" class="generateCopil btn btn-primary" data-id="<?php echo (string)$answer["_id"] ?>" data-date="<?php echo date("Y-m-d") ?>" data-title="Compte Rendu de la réunion de finalisation" data-key="copilReunionFinalisation">Générer le dossier validé</button>
<?php $pdf=Document::getListDocumentsWhere([ "id"=>(string)$answer["_id"], "type"=>Form::ANSWER_COLLECTION, "doctype"=>"file", "subKey"=>"pdf".$form['id'] ] ,"file");
?>
</td>
</tr>
<?php }
if(isset($answer["validation"][$form['id']]))
{
$color = "danger";
$lbl = "Non validé";
if(isset($answer["validation"][$form['id']]["valid"])){
if( $answer["validation"][$form['id']]["valid"] == "valid" ){
$color = "success";
$lbl = "Validé sans réserves";
} else if( $answer["validation"][$form['id']]["valid"] == "validReserve" ){
$color = "warning";
$lbl = "Validé avec réserves";
}
}
$editState = ( isset( $answer["validation"][$form['id']] ) ) ? "" : " <a href='javascript:;' data-type='".$form['id']."' class='validEdit btn btn-default btn-xs'><i class='fa fa-pencil'></i></a>";
?>
<table class="table table-bordered table-hover directoryTable" >
<tbody class="directoryLines">
<tr>
<td>Avis</td>
<td><h4 class="label label-<?php echo $color?>"><?php echo $lbl?></h4> <?php echo $editState ?></td>
<td colspan='2' ><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>">Validation</h4>
</td>
</tr>
<?php
if( isset( $answer["validation"][ $form['id'] ] ) )
{ ?>
<tr>
<td>Commentaire global</td>
<td><?php if( isset($answer["validation"][$form['id']]["description"] ) ) echo $answer["validation"][$form['id']]["description"]; ?></td>
<td colspan='2' align="center">
<button id="generateCopil2" class="generateCopil btn btn-primary" data-id="<?php echo (string)$answer["_id"] ?>" data-date="<?php echo date("Y-m-d") ?>" data-title="Compte Rendu de la réunion de finalisation" data-key="copilReunionFinalisation">Générer le dossier validé</button>
<?php $pdf=Document::getListDocumentsWhere([ "id"=>(string)$answer["_id"], "type"=>Form::ANSWER_COLLECTION, "doctype"=>"file", "subKey"=>"pdf".$form['id'] ] ,"file");