Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cAstraea/712679ffb413a108052a to your computer and use it in GitHub Desktop.
Save cAstraea/712679ffb413a108052a to your computer and use it in GitHub Desktop.
dependent fields for multi select
<?php
// created: 2016-03-08 14:50:30
//attempt repair
$sq = new SugarQuery();
$sq->select(array('id','name'));
$sq->from(BeanFactory::getBean('DP_actco'));
$result = $sq->execute();
$GLOBALS['app_list_strings']['v_objectifs_list'] = array();
foreach((array) $result as $row)
{
$GLOBALS['app_list_strings']['v_objectifs_list'][$row['id']] = $row['name'] ;
}
/*
$app_list_strings['v_objectifs_list']=array (
'01' => 'Formation Brichure',
'02' => 'Formation Espace Pro',
'03' => 'Activation Challenge',
'04' => 'Suivi Litige',
'05' => 'Contrôle livraison brochures',
'06' => 'Point sur CA',
);
*/
({ extendsFrom: 'RecordView',
initialize: function(options) {
this._super('initialize', [options]);
this.on("render", this.displayFunction, this);//launch it whenever your page is rendered
this.model.on("change:objectifs_c",this.displayFunction, this);//display changes when the multi select change
},
displayFunction:function(){
if (this.model.get('objectifs_c')) {
Array.prototype.contains = function ( needle ) {
for (i in this) {
if (this[i] == needle) return true;
}
return false;
};
console.log(this.model.get('objectifs_c'));
if (this.model.get('objectifs_c').contains("1") ||this.model.get('objectifs_c').contains("2") || this.model.get('objectifs_c').contains("6") || this.model.get('objectifs_c').contains("4")) {
$('[data-name="v_list_brochure"]').removeClass("vis_action_hidden").fadeIn().removeAttr("style");
}else{
// console.log(this.model.get('objectifs_c'));
//console.log(_.indexOf(this.model.get('objectifs_c')));
$('[data-name="v_list_brochure"]').addClass("vis_action_hidden");
}
if(this.model.get('objectifs_c').contains("8") ) { //geste CO sur Dossier
$('[data-name="v_pc_gco_motif"]').removeClass("vis_action_hidden").fadeIn().removeAttr("style");
$('[data-name="v_pc_gco_montant"]').removeClass("vis_action_hidden").fadeIn().removeAttr("style");
$('[data-name="v_pc_gco_pourcentage"]').removeClass("vis_action_hidden").fadeIn().removeAttr("style");
}
else {
$('[data-name="v_pc_gco_motif"]').addClass("vis_action_hidden");
$('[data-name="v_pc_gco_montant"]').addClass("vis_action_hidden");
$('[data-name="v_pc_gco_pourcentage"]').addClass("vis_action_hidden");
}
if(this.model.get('objectifs_c').contains("12") ) { //programation action commerciale
$('[data-name="v_liste_actionco"]').removeClass("vis_action_hidden").fadeIn().removeAttr("style");
}
else {
$('[data-name="v_liste_actionco"]').addClass("vis_action_hidden");
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment