Indiquez votre disponibilité de transport. Les chargeurs vous contacteront directement.
function fcSendAjax(fields, btn, msgId, btnText) { btn.disabled = true; btn.textContent = 'Publication en cours...'; var msg = document.getElementById(msgId); msg.className = 'fc-msg'; msg.style.display = 'none'; var nonce = (typeof fcForms !== 'undefined') ? fcForms.nonce : ''; var ajaxurl = (typeof fcForms !== 'undefined') ? fcForms.ajaxurl : '/wp-admin/admin-ajax.php'; var fd = new FormData(); fd.append('action', 'fretcom_create_listing'); fd.append('nonce', nonce); for (var k in fields) { if (fields[k]) fd.append(k, fields[k]); } fetch(ajaxurl, { method: 'POST', credentials: 'include', body: fd }) .then(function(r) { return r.json(); }) .then(function(d) { btn.disabled = false; btn.textContent = btnText; if (d && d.success) { msg.className = 'fc-msg success'; msg.innerHTML = '✅ Annonce publiée ! Voir l'annonce →'; } else { msg.className = 'fc-msg error'; msg.textContent = '❌ ' + (d.data ? d.data.message : 'Erreur lors de la publication.'); } msg.style.display = 'block'; msg.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); }).catch(function() { btn.disabled = false; btn.textContent = btnText; msg.className = 'fc-msg error'; msg.textContent = '❌ Erreur réseau.'; msg.style.display = 'block'; }); }
(function(){ document.querySelectorAll('#fc-capacite .fc-btn-group').forEach(function(grp){ grp.addEventListener('click',function(e){ var btn=e.target.closest('button');if(!btn)return; grp.querySelectorAll('button').forEach(function(b){b.classList.remove('selected');}); btn.classList.add('selected'); var h=document.getElementById(grp.id+'-val');if(h)h.value=btn.getAttribute('data-val'); }); }); })(); function fcValC(id){var el=document.getElementById(id);return el?el.value.trim():'';} function fcSubmitCapacite(){ var ok=true; var vt=fcValC('fc-vehicle-type-val'); var errVt=document.getElementById('err-vehicle-type'); if(!vt){errVt.style.display='block';ok=false;}else{errVt.style.display='none';} function req(id,errId){var el=document.getElementById(id);var err=document.getElementById(errId);if(!el||!el.value.trim()){if(err)err.style.display='block';ok=false;}else{if(err)err.style.display='none';}} req('fc-city-dep','err-city-dep');req('fc-avail-date','err-avail-date');req('fc-max-payload','err-max-payload'); if(!ok)return; var city=fcValC('fc-city-dep'); var fields={ title:'Capacité disponible'+(city?' \u2013 '+city:''), content:fcValC('fc-desc'), listivo_9144:'capacity', listivo_9153:vt, listivo_9163:city, listivo_9172:fcValC('fc-avail-date'), listivo_9179:fcValC('fc-max-payload'), listivo_9180:fcValC('fc-max-vol'), listivo_9181:fcValC('fc-max-pallets'), listivo_9182:fcValC('fc-max-length'), listivo_9162:fcValC('fc-country-dep'), listivo_9166:fcValC('fc-city-arr'), listivo_9154:fcValC('fc-loading-type-val'), listivo_9155:fcValC('fc-vehicle-equip-val'), listivo_9152:fcValC('fc-return-load-val'), listivo_9157:fcValC('fc-adr-cert-val'), listivo_9158:fcValC('fc-temp-cap-val'), listivo_9156:fcValC('fc-liftgate-val'), }; fcSendAjax(fields, document.getElementById('fc-sub-c'), 'fc-msg-c', 'Publier ma disponibilité \u2192'); }