1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
| function tableau_appareil(){
$(document).ready(function(){
$("#grid_appareil").jqGrid(
{ width: 1559,
height: 400,
autowidth: false,
rownumbers: true,
rownumWidth: 40,
url:'appareil/tableau',
editurl:'appareil/modifier',
datatype: 'json',
mtype: 'POST',
colNames:['No','Utilisateur','Type Appareil','Statut','Forfait','Numero telephone','Type Abonnement','Code PUK','Numero de serie','Numero SBE','Date Achat','Date Reception','Date Fin Garantie'],
colModel :[
{name:'id', index:'id',
width:10,
height:20,
hidden:true
},
{name:'UTILISATEUR_ID_UTILISATEUR', index:'UTILISATEUR_ID_UTILISATEUR',
width:23,
height:20,
sortable:true,
editable:true,
// stype:"select",
classes: "clickable",
edittype: "select",
editoptions:{size:1, ajaxSelectOptions: {type: "POST",datatype:"json"}, dataUrl:'utilisateurs/select'} //créer un select dans le formulaire
},
{name:'TYPE_APPAREIL_ID_TYPE_APPAREIL', index:'TYPE_APPAREIL_ID_TYPE_APPAREIL',
width:10,
height:20,
sortable:true,
editable:true,
classes: "clickable",
edittype: "select",
editoptions:{size:1, ajaxSelectOptions: {type: "POST",datatype:"json"}, dataUrl:'appareil/selecttypeappareil'} //créer un select dans le formulaire
},
{name:'STATUT_APPAREIL_ID_STATUT_APPAREIL', index:'STATUT_APPAREIL_ID_STATUT_APPAREIL',
width:10,
height:25,
sortable:true,
editable:true,
stype:"select",
classes: "clickable",
edittype: "select",
searchoptions:{defaultValue:'-', ajaxSelectOptions: {type: "POST",datatype:"json"}, dataUrl:'appareil/selectstatut'}, //créer une select dans le filtertoolbar
editoptions:{defaultValue:'-', ajaxSelectOptions: {type: "POST",datatype:"json"}, dataUrl:'appareil/selectstatut'} //créer un select dans le formulaire
},
{name:'ID_FORFAIT', index:'ID_FORFAIT',
width:20,
height:20,
sortable:false,
editable:true,
hidden:true,
classes: "clickable",
edittype: "select",
editoptions:{size:1, ajaxSelectOptions: {type: "GET",datatype:"json",cache: false,async:false}, dataUrl:'appareil/selectforfait'} //créer un select dans le formulaire
//editrules:{edithidden:true}//permet d'afficher le champ que dans le formulaire d'edition alors qu'il n'est pas présent dans le tableau
},
{name:'NUMERO', index:'NUMERO',
width:10,
height:25,
sortable:true,
editable:false,
classes: "clickable",
editoptions:{size:30}
},
{name:'TYPE_FORFAIT', index:'TYPE_FORFAIT',
width:20,
height:20,
sortable:true,
editable:false,
stype:"select",
classes: "clickable",
searchoptions:{defaultValue:'-', ajaxSelectOptions: {type: "POST",datatype:"json"}, dataUrl:'forfait/select'} //créer une select dans le filtertoolbar
// editoptions:{size:1, ajaxSelectOptions: {type: "POST",datatype:"json"}, dataUrl:'forfait/select'} //créer un select dans le formulaire
},
{name:'CODE_PUK', index:'CODE_PUK',
width:10,
height:20,
sortable:true,
editable:false,
classes: "clickable",
editoptions:{size:30}
},
{name:'NUMERO_SERIE', index:'NUMERO_SERIE',
width:10,
height:20,
sortable:true,
editable:true,
classes: "clickable",
editoptions:{size:30}
},
{name:'NUMERO_SBE', index:'NUMERO_SBE',
width:10,
height:20,
sortable:true,
editable:true,
classes: "clickable",
editoptions:{size:30}
},
{name:'DATE_ACHAT', index:'DATE_ACHAT',
width:10,
height:20,
sortable:true,
editable:true,
classes: "clickable",
searchoptions:{dataInit:datePick = function(elem)
{
jQuery(elem).datepicker();
}, attr:{title:'Select Date'}},
editoptions:{size:30,dataInit:datePick = function(elem)
{
jQuery(elem).datepicker();
},
attr:{title:'Select Date'}}
},
{name:'DATE_RECEPTION', index:'DATE_RECEPTION',
width:10,
height:20,
sortable:true,
editable:true,
classes: "clickable",
searchoptions:{dataInit:datePick = function(elem)
{
jQuery(elem).datepicker();
}, attr:{title:'Select Date'}},
editoptions:{size:30,dataInit:datePick = function(elem)
{
jQuery(elem).datepicker();
},
attr:{title:'Select Date'}}
},
{name:'DATE_FIN_GARANTIE', index:'DATE_FIN_GARANTIE',
width:10,
height:20,
sortable:true,
editable:true,
classes: "clickable",
searchoptions:{dataInit:datePick = function(elem)
{
jQuery(elem).datepicker();
}, attr:{title:'Select Date'}},
editoptions:{size:30,dataInit:datePick = function(elem)
{
jQuery(elem).datepicker();
},
attr:{title:'Select Date'}}
}
],
pager: '#naviguation',
pgbuttons: true,
caption: "Liste des Appareils",
viewrecords: true,
search: true,
rowList:[10,20,30],
sortorder: 'desc',
gridComplete: function() {
$(".clickable").each(function() {
$(this).click(function() {
var idLigne = $(this).parent().attr("id"); //on récupère l'id de l'appareil
//permet d'envoyer des données à notre select via la propriété setcolprop qui modifie l'url qui charge le select dans lequel on enenvoi notre id
$("#grid_appareil").setColProp('ID_FORFAIT', { editoptions: { dataUrl:'appareil/selectforfait?id='+idLigne}});
$.ajax({
url: 'historique/affichehistorique',
type: 'POST',
data: {numerocc: idLigne},
dataType: 'text',
beforeSend: function() {
},
error: function(msg) {
toastr.error('Une erreur s\'est produite--');
},
success: function(msg) {
//toastr.success('Mise à jour du : '+msg);
$("#div_historique").empty();
$("#div_historique").append(msg);
}
});
});
});
}
}
);
jQuery("#grid_appareil").filterToolbar({
autosearch:true,
searchOnEnter:true,
operandTitle: "Recherche",
stringResult:false});
jQuery("#grid_appareil").navGrid('#naviguation',{
add:false,
del:true,
edit:true,
search:false,
view:true,
closeOnEscape:true
//recreateForm permet de recharger le formulaire d'edition et donc de refaire le select à chaque fois
},{recreateForm: true,/* edition*/beforeShowForm: function(form) { $('#tr_ID_FORFAIT', form).show();}},{/*add*/},{},{
beforeShowForm: function(form) { $('#tr_ID_FORFAIT', form).show(); }
}
);
$("#naviguation").css('height', '30px'); //hauteur barre navigation
$("#naviguation div.ui-paging-info").css({float:"left"});
});
} |
Partager