Commit a980304c authored by Clément Damiens's avatar Clément Damiens
Browse files

services form + openingHours sytem

parent 09481149
......@@ -4170,7 +4170,7 @@ var dyFInputs = {
};
return inputObj;
},
allDay : function(checked){
allDay : function(checked, timepicker, domSpec){
var inputObj = {
inputType : "checkbox",
......@@ -4185,10 +4185,13 @@ var dyFInputs = {
"offText" : tradDynForm["no"],
"labelText":tradDynForm["allday"],
"onChange" : function(){
var allDay = $("#ajaxFormModal #allDay").is(':checked');
domAdd="";
if(typeof domSpec != "undefined" && notNull(domSpec))
domAdd=domSpec;
var allDay = $("#ajaxFormModal #allDay"+domAdd).is(':checked');
var startDate = "";
var endDate = "";
$("#ajaxFormModal #allDay").val($("#ajaxFormModal #allDay").is(':checked'));
$("#ajaxFormModal #allDay"+domAdd).val($("#ajaxFormModal #allDay"+domAdd).is(':checked'));
if (allDay) {
$(".dateTimeInput").addClass("dateInput");
......@@ -4223,6 +4226,106 @@ var dyFInputs = {
};
return inputObj;
},
openingHours : function(checked){
var inputObj = {
inputType : "checkbox",
label : "Availabity of your service",
checked : ( notEmpty(checked) ? checked : "" ),
init : function(){
var openingHoursResult=[
{"dayOfWeek":"Su","allDay":true},
{"dayOfWeek":"Mo","allDay":true},
{"dayOfWeek":"Tu","allDay":true},
{"dayOfWeek":"We","allDay":true},
{"dayOfWeek":"Th","allDay":true},
{"dayOfWeek":"Fr","allDay":true},
{"dayOfWeek":"Sa","allDay":true},
];
//jQuery.datetimepicker.setLocale('fr');
//$('.changeTime').datetimepicker({format:"HH:MM"});
$(".btn-select-day").click(function(){
key=$(this).data("key");
if($(this).hasClass("active")){
$(this).removeClass("active");
$.each(openingHoursResult, function(e,v){
if(v.dayOfWeek==key){
openingHoursResult[e].disabled=true;
console.log("opening",openingHoursResult);
}
});
$("#contentDays"+key).fadeOut();
}else{
$(this).addClass("active");
$.each(openingHoursResult, function(e,v){
if(v.dayOfWeek==key){
delete openingHoursResult[e].disabled;
console.log("opening",openingHoursResult);
}
});
$("#contentDays"+key).fadeIn();
}
});
$(".allDaysWeek").click(function(){
keyRange=$(this).data("key");
//alert(keyRange);
if($(this).is(':checked')){
$("#hoursRange"+keyRange).fadeOut("slow");
$.each(openingHoursResult, function(e,v){
if(v.dayOfWeek==keyRange){
openingHoursResult[e].allDay=true;
console.log("opening",openingHoursResult);
}
});
}else{
$("#hoursRange"+keyRange).fadeIn("slow");
$.each(openingHoursResult, function(e,v){
if(v.dayOfWeek==keyRange){
openingHoursResult[e].allDay=false;
console.log("opening",openingHoursResult);
}
});
}
});
/*$("#ajaxFormModal #allWeek").off().on("switchChange.bootstrapSwitch",function (e, data) {
mylog.log("allDay dateLimit",$("#ajaxFormModal #allWeek").val());
});*/
/*initbootstrapSwitch("#ajaxFormModal .allDaysWeek", function($this){
keyRange=$this.data("key");
if($("#ajaxFormModal .allDaysWeek").is(':checked')){
$("#hoursRange"+keyRange).fadeIn("slow");
}else{
$("#hoursRange"+keyRange).fadeOut("slow");
}
});*/
//$("#ajaxFormModal .allDaysWeek").off().on("switchChange.bootstrapSwitch",function (e, data) {
//mylog.log("allDay dateLimit",$("#ajaxFormModal .allDaysWeek").val());
//});
},
options: {"allWeek" : true},
"switch" : {
"onText" : tradDynForm["yes"],
"offText" : tradDynForm["no"],
"labelText":tradDynForm["allweek"],
"css":{"min-width": "300px","margin": "10px"},
"onChange" : function(){
var allWeek = $("#ajaxFormModal #openingHours").is(':checked');
$("#ajaxFormModal #openingHours").val($("#ajaxFormModal #openingHours").is(':checked'));
if (allWeek) {
$("#ajaxFormModal #selectedDays").fadeOut("slow");
} else {
$("#ajaxFormModal #selectedDays").fadeIn("slow");
}
//if (startDate != "Invalid date") $('#ajaxFormModal #startDate').val(startDate);
//if (endDate != "Invalid date") $('#ajaxFormModal #endDate').val(endDate);
}
},
};
return inputObj;
},
startDateInput : function(typeDate){
mylog.log('startDateInput', typeDate);
var inputObj = {
......@@ -4442,8 +4545,10 @@ var typeObj = {
contactPoint : {col : "contact" , ctrl : "person",titleClass : "bg-blue",bgClass : "bgPerson",color:"blue",icon:"user",
saveUrl : baseUrl+"/" + moduleId + "/element/saveContact"},
"product":{ col:"products",ctrl:"product", titleClass : "bg-orange", color:"orange", icon:"gift"},
"product":{ col:"products",ctrl:"product", titleClass : "bg-orange", color:"orange", icon:"shopping-basket"},
"products" : {sameAs:"product"},
"service":{ col:"services",ctrl:"service", titleClass : "bg-green", color:"green", icon:"sun-o"},
"services" : {sameAs:"service"},
"classified":{ col:"classified",ctrl:"classified", titleClass : "bg-azure", color:"azure", icon:"bullhorn",
subTypes : [
//FR
......
dynForm = {
jsonSchema : {
title : "Add a services",
icon : "sun-o",
type : "object",
onLoads : {
//pour creer un subevnt depuis un event existant
sub : function(){
if(typeof contextData != "undefined" && contextData != null && contextData.type && contextData.id ){
$('#ajaxFormModal #parentId').val(contextData.id);
$("#ajaxFormModal #parentType").val( contextData.type );
$("#ajax-modal .modal-header").removeClass("bg-dark bg-purple bg-red bg-azure bg-green bg-green-poi bg-orange bg-yellow bg-blue bg-turq bg-url")
.addClass("bg-azure");
$("#ajaxFormModal #toBeValidated").val(true);
$("#ajax-modal-modal-title").html(
$("#ajax-modal-modal-title").html()+
" <br><small class='text-white'>"+tradDynForm["speakingas"]+" : <span class='text-dark'>"+contextData.name+"</span></small>" );
}
},
onload : function(data){
},
/*,
loadData : function(data){
mylog.warn("--------------- loadData ---------------------",data);
$('#ajaxFormModal #name').val(data.name);
$('#ajaxFormModal #type').val(data.type);
$('#ajaxFormModal #parentId').val(data.parentId);
$("#ajaxFormModal #parentType").val( data.parentType );
},*/
},
beforeBuild : function(){
dyFObj.setMongoId('products',function(){
uploadObj.gotoUrl = (contextData != null && contextData.type && contextData.id ) ? "#page.type."+contextData.type+".id."+contextData.id+".view.directory.dir.classified" : location.hash;
});
},
beforeSave : function(){
var tagAndTypes = ( $("#ajaxFormModal #tags").val() != "" ) ? $("#ajaxFormModal #tags").val()+"," : "" ;
$("#ajaxFormModal #tags").val( tagAndTypes );
if( typeof $("#ajaxFormModal #description").code === 'function' )
$("#ajaxFormModal #description").val( $("#ajaxFormModal #description").code() );
if($('#ajaxFormModal #parentId').val() == "" && $('#ajaxFormModal #parentType').val() ){
$('#ajaxFormModal #parentId').val(userId);
$("#ajaxFormModal #parentType").val( "citoyens" );
}
},
afterSave : function(){
if( $('.fine-uploader-manual-trigger').fineUploader('getUploads').length > 0 )
$('.fine-uploader-manual-trigger').fineUploader('uploadStoredFiles');
else {
dyFObj.closeForm();
loadProducts();
//urlCtrl.loadByHash( (uploadObj.gotoUrl) ? uploadObj.gotoUrl : location.hash );
}
},
properties : {
info : {
inputType : "custom",
html:"",//<p><i class='fa fa-info-circle'></i> Une Annonce est un élément assez libre qui peut etre géolocalisé ou pas, qui peut etre rataché à tous les éléments.</p>",
},
breadcrumb : {
inputType : "custom",
html:"",
},
type : dyFInputs.inputSelect(tradDynForm["servicesTypes"],null,servicesList, { required : true }),
price : dyFInputs.price(),
//devise : dyFInputs.inputSelect("Devise", "Iniquez la monnaie utilisée pour votre annonce", ["€", "$"]),
name : dyFInputs.name( "service" ) ,
openingHours : dyFInputs.openingHours(true),
description : dyFInputs.textarea("Description", "..."),
image : dyFInputs.image(),
medias : dyFInputs.videos,
contactInfo : dyFInputs.inputText(tradDynForm["contactinfo"], tradDynForm["telemail"]+" ..."),
location : dyFInputs.location,
tags : dyFInputs.tags(),
parentId : dyFInputs.inputHidden(),
parentType : dyFInputs.inputHidden(),
toBeValidated : dyFInputs.inputHidden(),
}
}
};
\ No newline at end of file
......@@ -399,7 +399,7 @@
<!-- </div> -->
<?php } else{
$prestation = CO2::getContextList("prestation");
$service = CO2::getContextList("service");
?>
<div class="col-lg-2 col-md-3 col-sm-3 col-md-offset-1 col-sm-offset-1 col-xs-12 margin-top-25 text-left subsub no-padding shadow2" id="sub-menu-left">
<h4 class="bg-orange text-white no-margin padding-10">FILTRE</h4>
......@@ -408,7 +408,7 @@
</div>
<hr>
<?php
foreach ($prestation["categories"] as $key => $cat) {
foreach ($service["categories"] as $key => $cat) {
?>
<div class="col-md-12 text-dark margin-bottom-5">
<input type="checkbox" class="btn-select-category-1" data-keycat="<?php echo $key; ?>"> <?php echo Yii::t("category",$cat); ?>
......@@ -468,7 +468,7 @@
<?php } ?>
<?php if($typeSelected != "classified" && Yii::app()->params["CO2DomainName"] == "terla"){
$prestation = CO2::getContextList("prestation");
$service = CO2::getContextList("service");
?>
<div class="col-lg-2 col-md-3 col-sm-3 col-md-offset-1 col-sm-offset-1 col-xs-12 margin-top-25 text-left subsub no-padding shadow2" id="sub-menu-left">
<h4 class="bg-orange text-white no-margin padding-10">FILTRE</h4>
......@@ -477,7 +477,7 @@
</div>
<hr>
<?php
foreach ($prestation["categories"] as $key => $cat) {
foreach ($service["categories"] as $key => $cat) {
?>
<div class="col-md-12 text-dark margin-bottom-5">
<input type="checkbox" class="btn-select-category-1" data-keycat="<?php echo $key; ?>"> <?php echo Yii::t("category",$cat); ?>
......
......@@ -69,7 +69,7 @@ HtmlHelper::registerCssAndScriptsFiles($cssAnsScriptFilesTheme, Yii::app()->requ
<h6><i class="fa fa-shopping-basket fa-2x"></i><br> <?php echo Yii::t("common", "Product") ?></h6>
<small><?php echo Yii::t("form","Food, hand-made, jewelery...<br>Sell your product here") ?></small>
</button>
<button data-form-type="organization" data-form-subtype=""
<button data-form-type="service" data-form-subtype=""
data-dismiss="modal"
class="btn btn-link btn-open-form col-xs-6 col-sm-4 col-md-4 col-lg-4 text-green">
<h6><i class="fa fa-sun-o fa-2x"></i><br> <?php echo Yii::t("common", "Services") ?></h6>
......@@ -90,7 +90,7 @@ HtmlHelper::registerCssAndScriptsFiles($cssAnsScriptFilesTheme, Yii::app()->requ
jQuery(document).ready(function() {
list.initList(listElement, actionType);
$(".btn-open-form").click(function(){
dyFObj.openForm("product","sub");
dyFObj.openForm($(this).data("form-type"),"sub");
});
bindLBHLinks();
})
......
......@@ -376,6 +376,7 @@ var tradDynForm = {
"yes":"<?php echo Yii::t("common","Yes") ?>",
"no":"<?php echo Yii::t("common","No") ?>",
"allday":"<?php echo Yii::t("form","All the day") ?>",
"allweek":"<?php echo Yii::t("form","All the week") ?>",
"startDate":"<?php echo Yii::t("form","Start date") ?>",
"endDate":"<?php echo Yii::t("form","End date") ?>",
"theendDate":"<?php echo Yii::t("form","the start date") ?>",
......
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