How can i display multiple views with ModuleFrontController in PS 1.6 - prestashop

With my Module Front Controller, i need to initialize it to display a form (formulaire.tpl) that the customer has to fill. Then the controller processes the data posted from the form using methods defines in my model (Formulaire.php) and then i would like to make it display another view (recapitulatif.tpl) that displays a reminder of data sent, an add to cart button for example or the possibility to fill the form in again.
As i would like to implement it the MVC way, i don't want to create a new php page to redirect my customer to but i would like to display somehow this second template after processing the data. Is there any way to do so with the controller? Here below, you can find my code, it doesn't work and it displays my first template and below my second..
class FormulaireModuleDefaultModuleFrontController extends ModuleFrontController
{
public $ssl = true;
private $done_traitement = false;
public function postProcess()
{
//On vérifie le bouton submit du formulaire
if(Tools::isSubmit('bouton'))
{
// On va commencer en premier par récupérer l'id customer avec la variable cookie
// et vérifier que la personnes est bien loggée
global $cookie;
if(!isset($cookie->id_customer))
{
$message='Aucun client loggé';
}
else
{
$errors=array();
$id_cart=$this->context->cart->id;
$customer=$cookie->id_customer;
//On récupère les valeurs du formulaire
$prix=Tools::getValue('resultat');
$titre='porte_test';
$desc='Largeur de passage de '.Tools::getValue('largeur_passage').' mm, hauteur de passage de '.Tools::getValue('hauteur_passage')
.' mm, hauteur de linteau de '.Tools::getValue('hauteur_linteau').' mm, ecoinçon gauche de '.Tools::getValue('ecoincon_gauche')
.' mm, ecoincon_droit de '.Tools::getValue('ecoincon_droit'). ' mm, motif en '.Tools::getValue('motif_porte').' et de couleur '
.Tools::getValue('couleur_porte');
//On va vérifier les champs obligatoires
//Les champs sont remplis, on va faire le traitement des données.
$idprod=Formulaire::creerProduct($titre,0,13,$prix,$desc, 'mod_100',$customer);
Formulaire::addProduitauPanier($idprod);
$this->done_traitement=true;
}
//On envoie le message si il existe:
if(isset($message))self::$smarty->assign('message',$message);
if(isset($errors))self::$smarty->assign('erreurs',$errors);
}
}
public function initContent()
{
parent::initContent();
if($this->done_traitement)
$this->display(__FILE__,'recapitulatif.tpl');
}
public function init(){
$this->display_column_left = false;
$this->display_column_right = false;
$this->page_name = 'Configurateur';
parent::init();
$this->setTemplate('formulaire.tpl');
}
}
Thanks in advance for your help !
EDIT :
Ok sorry for the question. It just took me 2 minutes to figure it out after posting the question. I only needed to change:
$this->display(__FILE__,'recapitulatif.tpl');
by :
$this->setTemplate('recapitulatif.tpl');
And now it works. Sorry for the inconvenience !

Related

insertion dans une base de données Rpostgres [closed]

Closed. This question is not written in English. It is not currently accepting answers.
Stack Overflow is an English-only site. The author must be able to communicate in English to understand and engage with any comments and/or answers their question receives. Don't translate this post for the author; machine translations can be inaccurate, and even human translations can alter the intended meaning of the post.
Closed 5 days ago.
Improve this question
Bonjour à tous, je vous écris ici car j'ai un soucis j'apprend a utiliser R et Postgres je ne sais pas si je suis au bon endroit .
j'ai importé plusieurs fichiers cvs dans R et j'ai essayé d'inserer leurs données dans Postgres . La première insertion a marché
mais toutes les autres tentatives d'enregistrement ne marchent pas.
files<-scale
files
# INSERTION DANS LA BASE DE DONNEES
# Pour chaque ligne de données
for (i in 1:nrow(files)) {
# Vérification si la ligne existe déjà dans la table
result <- dbGetQuery(con, paste0("SELECT * FROM scale WHERE scale_code = '",
files[i,1], "' " ))
# Si la ligne n'existe pas déjà, l'insérer
if (nrow(result) == 0) {
dbGetQuery(con, paste0("INSERT INTO scale (scale_code, scale_name, scale_type, scale_level) VALUES ('",
files[i,1], "', '",files[i,2], "','",files[i,3], "','",files[i,4], "' )"))
}
}
je n'ai aucune erreur mais en consultant la table scale aucune données n'est ajoutée. Que faire?

Display a message between a date range in velocity language

I want to display a message between a date range in Velocity language. Like from 1/3/2023 to 23/3/2023. How can I do that.
I tried to put condition but it's not working.
#set($user = SpermissionChecker.getUser() if (Guser.female)
#set($genre = "Madame")
#else
#set($genre = "Monsieur")
#end
#get (fact-Suser.getExpandoBridge ().getAttribute("active_"))
if("$/act"=="RESILIE"}
Suite à la résiliation de votre contrat, l'acces
contenu est limité à 6 mois, nous vous conseillons de sauvegarder vos documer
#set ($timete dateUtil.getCurrentDate ("dd/MM/yyyy", Locale))
#end
#if($timet =="03/12/2022" && $timet =="10/12/2022")
Rapprochement des banques du Groupe Crédit du Nord et portail et votre application mobile Santé évoluent </span

Diplay loading indicator for FullCalendar and Vuejs

is there a way to display a loading indicator on FullCalendar 5 and VueJS ?
https://fullcalendar.io/docs/loading
I checked the documentation and it states it works via AJAX request, but don't say anything about other technologies.
Is there any way to have something similar and easy to implement ?
Regards.
When i get my agendas entries, i update my calendars with the events.
entreesAgenda() {
// Ajout des evenements dans le(s) calendrier(s)
let entrees = []
if (this.entreesAgenda) {
for (let i = 0; i < this.utilisateurs.length; i++) {
entrees = this.data.items.filter(
(f) => f.idPersonnel === this.utilisateurs[i].id
)
// Mise à jour des businessHours
this.$refs.utilisateur[i]
.getApi()
.setOption('businessHours', this.calculBusinessHours(entrees))
// Insertion des entrees d'agenda dans le calendrier
for (let m = 0; m < entrees.length; m++) {
this.$refs.utilisateur[i].getApi().addEvent(entrees[m])
}
}
}
this.updateView()
},
But i don't know how to use the loading.

static class on .web project silverlight

I have been having a problem for a long time , but so far have not got a solution and I hope you can help me .
I have a Silverlight application where I use WCF for queries to retrieve information from the database and also for the communication between client ( Duplex ) and Socket (receive and send information between my application and others).
To control Duplex , when the client accesses a specific module of my application , I link that customer to a static class that I have on my Projeto.Web ( Application start ) , as in the code below :
//static Class
public static class ncClientes
{
private static List<IncServicoDuplex> clientesSupRecAlarme = new List<IncServicoDuplex>();
public static List<IncServicoDuplex> ClientesSupRecAlarme
{
get { return ncClientes.clientesSupRecAlarme; }
set { ncClientes.clientesSupRecAlarme = value; }
}
}
//Método chamado pelo WCF quando o cliente acessa o módulo
public void VinculaCliente(string strProjeto)
{
//GetCallbackChannel - obter o canal de comunicação entre o serviço e o cliente - retornará a instância do canal entre o serviço e o cliente.
IncServicoDuplex cliente = OperationContext.Current.GetCallbackChannel<IncServicoDuplex>();
//A palavra-chave lock marca um bloqueio de instruções como uma seção crítica, obter o bloqueio de exclusão de mútua para um determinado objeto,
//executar uma instrução e, em seguida, liberar o bloqueio.
switch (strProjeto)
{
case "ncPrincipal|Alarme":
case "ncAlarme":
case "ncConfiguracao|Supervisao":
lock (ncClientes.ClientesSupRecAlarme)
{
ncClientes.ClientesSupRecAlarme.Add(cliente);
}
break;
}
}
When I make a change to the database , all of my online customers who are at the receiving module that change the WCF service , use the following code :
//Método no meu WCF que transmite a informação de alteração, inclusão ou exclusão de um cliente para os outros
public void SupervisaoAlarmeOnline(ncAlarme objAlarme)
{
var varClientesAlarme = new List<IncServicoDuplex>(ncClientes.ClientesSupRecAlarme);
foreach (var item in varClientesAlarme)
{
try
{
item.SupervisaoAlarmeOnlineRetorno(objAlarme);
}
catch
{
ncClientes.ClientesSupRecAlarme.Remove(item);
}
}
}
My problem happens when I get some information by Socket ( class located in projeto.Web ) that creates an instance of my ServicoWCF and call the method to send the received information to clients. Apparently, my static variable is being reset when called on this side of the application.
Is there any difference on " which side " I call the service ? When I call it on WCF client side my static variable gets the correct count , but when I call it on the Socket class , count is set to 0.
I hope you can help me , I tried to be as clear as possible , if there is any doubt please let me know.
Thanks in advance !

Set the WebView content

Am consuming a JSON rest service from the web. That JSON has a property called "content", wich is a HTML content, so the JSON file is something like:
[{
"id":"4205",
"title":"SomeTitle",
"author":"Homero Simpson",
"content":"<html><head></head><body>Había una vez un molinero cuya única herencia para sus tres hijos eran su molino, su <a href='biblioSonidos://soundID=67'>asno</a> y su <a href='biblioSonidos://soundID=69'>gato</a>. Pronto se hizo la repartición sin necesitar de un clérigo ni de un abogado, pues ya habían consumido todo el pobre patrimonio. Al mayor le tocó el molino, al segundo el asno, y al menor el gato que quedaba. El pobre joven amigo estaba bien inconforme por haber recibido tan poquito. 'Mis hermanos' dijo él, 'pueden hacer una bonita vida juntando sus bienes, pero por mi parte, después de haberme comido al gato, y hacer unas sandalias con su piel, entonces no me quedará más que morir de hambre.' El gato, que oyó todo eso, pero no lo tomaba así, le dijo en un tono firme y serio: 'No te preocupes tanto, mi buen amo. Si me das un bolso, y me tienes un par de botas para mí, con las que yo pueda atravesar lodos y zarzales, entonces verás que no eres tan pobre conmigo como te lo imaginas.'</body></html>"
}]
I need to create a WebView with the code in the "content" property.
So, my question is:
How can set the WebView content from this JSON property?
Is that possible?
Use JSONSerialization to convert the JSON file to a foundation object (which will be an NSDictionary). Then use loadHTMLString to load the value for the content key:
NSError *jsonError = nil;
id json = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:pathToTheJSONFile] options:0 error:&jsonError];
if (json) {
[webView loadHTMLString:[(NSDictionary *)json objectForKey:#"content"] baseURL:nil];
} else {
NSLog(#"Error loading JSON: %#", jsonError);
}
(Pass whatever's appropriate for baseURL instead of nil if you want relative links in the content to work.)