Commit 1918f5f0 authored by Ifaliana Arimanana's avatar Ifaliana Arimanana
Browse files

Merge remote-tracking branch 'origin/qa' into qa

parents ade1123f 0682da47
......@@ -152,10 +152,31 @@ class PaymentController extends CommunecterController {
}
}
public function actionGetPaymentMethode()
public function actionGetPaymentMethods()
{
$payment_methode = array();
return Rest::json($payment_methode);
$mollie = new \Mollie\Api\MollieApiClient();
$request = Yii::app()->request;
$param1 = $request->getPost("param1");
$param2 = $request->getPost("param2");
$coform_params = PHDB::findOne(Form::COLLECTION, array('id' => $param1));
$api_key = "";
if(isset($coform_params["params"][$param2]["mollieMode"])){
$mode = $coform_params["params"][$param2]["mollieMode"];
$api_key = base64_decode($coform_params["params"][$param2]["api".$mode]);
}
$methods = array();
if($api_key!=""){
$mollie->setApiKey($api_key);
// Methods for the Payments API
$methods = $mollie->methods->allActive();
}
return Rest::json($methods);
}
public function actionInvoice($id=null, $slug=null, $user=null, $form=null) {
......
......@@ -7,6 +7,14 @@
.form-control{
padding: .5em !important;
}
.p-1{
padding: .5em;
}
.align-bottom{
vertical-align: bottom;
}
</style>
<?php if($answer){ ?>
......@@ -223,38 +231,21 @@
</div>
<?php } ?>
</div>
<div class="col-md-6 align-bottom">
<br><br>
<div id="methods"></div>
</div>
<script type="text/javascript">
sectionDyf.<?php echo $kunik ?>ParamsData = <?php echo json_encode( $paramsData ); ?>;
var typeAssocie = <?php echo json_encode( $types ); ?>;
var typeAssocie = <?php echo json_encode( $types ); ?>;
var isPaid = <?php echo json_encode($isPaid); ?>;
var paymentStatus = <?php echo json_encode($paymentStatus); ?>;
// Initialize from answers
$("#nbPart").val("<?= $nb_part ?>");
$("#select<?=$key?>").val("<?= $selected_type ?>");
if(isPaid || paymentStatus=="open" || paymentStatus=="pending" || paymentStatus=="settled"){
$("#btn-payement").attr("disabled", true);
$("#btn-payement").hide();
$("#select<?=$key?>").attr("disabled", true);
$("#nbPart").attr("disabled", true);
}else{
if($("#select<?=$key?>").val()!=""){
$("#btn-payement").attr("disabled", false);
}
}
if($("#select<?=$key?>").val()!=""){
const st = JSON.parse(atob($("#select<?= $key ?>").val()));
$("#total").text(st.droit*$("#nbPart").val()+"");
}
$(document).ready(function(){
let kunik = "<?= $kunik ?>";
let droit = {};
let options = [];
......@@ -263,6 +254,43 @@
let isSetApiTest = "<?= json_encode($paramsData['isSetApiTest'])?>";
let isSetApiLive = "<?= json_encode($paramsData['isSetApiLive'])?>";
// Initialize from answers
$("#nbPart").val("<?= $nb_part ?>");
$("#select<?=$key?>").val("<?= $selected_type ?>");
if(isPaid || paymentStatus=="pending" || paymentStatus=="settled"){
$("#btn-payement").attr("disabled", true);
$("#btn-payement").hide();
$("#select<?=$key?>").attr("disabled", true);
$("#nbPart").attr("disabled", true);
}else{
if($("#select<?=$key?>").val()!=""){
$("#btn-payement").attr("disabled", false);
}
ajaxPost(
null,
baseUrl+"/survey/payment/getpaymentmethods",
{param1:thisForm, param2:kunik},
function(response){
for(const index in response) {
$("#methods").append('<img src="'+response[index]["image"]["size2x"]+'" class="p-1">');
}
},
function(error){
toastr.warning("Veuillez recharger la page pour voir tout les methodes de payments");
}
);
}
if($("#select<?=$key?>").val()!=""){
const st = JSON.parse(atob($("#select<?= $key ?>").val()));
$("#total").text(st.droit*$("#nbPart").val()+"");
}
sectionDyf.<?php echo $kunik ?>ParamsSelect = {
"jsonSchema" : {
"title" : "Paramétrage du <?php echo $kunik ?>",
......@@ -362,6 +390,22 @@
}
};
$(document).on('change','#select<?= $key ?>, #nbPart',function(){
var nbPartValue = (!isNaN($("#nbPart").val()) && $("#nbPart").val()!=0)?$("#nbPart").val():1;
var st = ($("#select<?= $key ?>").val()!="")?JSON.parse(atob($("#select<?= $key ?>").val())):0;
//alert(st.droit+" - "+nbPartValue);
$("#total").text(st.droit*$("#nbPart").val()+"");
if(st.droit*$("#nbPart").val()==0){
$("#btn-payement").attr("disabled", true);
}else{
$("#btn-payement").text("Proceder au paiement de "+st.droit*$("#nbPart").val()+"");
$("#btn-payement").attr("disabled", false);
}
$(this).blur();
});
$("#btn-payement").off().on("click", function(){
// Save all before pay
$(".saveOneByOne").blur();
......@@ -404,10 +448,6 @@
}
});
$("#btn-facturation").off().on("click", function(){
});
//adds a line into answer
$(".add<?php echo $kunik ?>").off().on("click",function() {
tplCtx.id = $(this).data("id");
......@@ -434,22 +474,6 @@
});
});
$("#select<?= $key ?>, #nbPart").off().on("change", function(){
const nbPartValue = (!isNaN($("#nbPart").val()) && $("#nbPart").val()!=0)?$("#nbPart").val():1;
const st = ($("#select<?= $key ?>").val()!="")?JSON.parse(atob($("#select<?= $key ?>").val())):0;
alert(st.droit+" - "+nbPartValue);
$("#total").text(st.droit*$("#nbPart").val()+"");
if(st.droit*$("#nbPart").val()==0){
$("#btn-payement").attr("disabled", true);
}else{
$("#btn-payement").text("Proceder au paiement de "+st.droit*$("#nbPart").val()+"");
$("#btn-payement").attr("disabled", false);
}
$(this).blur();
});
</script>
<?php } else {
//echo "<h4 class='text-red'>evaluation works with existing answers</h4>";
......
......@@ -226,7 +226,7 @@ if( isset($parentForm["subForms"]) && count($parentForm["subForms"]) > 1 ) {
<?php } else if( isset($parentForm["subForms"]) && count($parentForm["subForms"]) == 1 ) {
echo "<div class='col-xs-12'>";
echo '<h2 class="text-center" style="color:'.$color1.'" >'.@$forms[$parentForm["subForms"][0]]["name"].'</h2>';
if(!isset($preview)){
if(!isset($preview) && $canEditForm === true){
echo "<div class='text-center col-xs-12'>";
echo '<a href="javascript:;" class="editFormBtn" data-id="'.$forms[$parentForm["subForms"][0]]["_id"].'" data-formid="'.$parentForm["subForms"][0].'"><i class="fa fa-pencil text-dark"></i></a> ';
echo '<a href="javascript:;" class="deleteFormBtn" data-id="'.$forms[$parentForm["subForms"][0]]["_id"].'" data-formid="'.$parentForm["subForms"][0].'"><i class="fa fa-trash text-red"></i></a> ';
......
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