get('roleid'); $viewer = new Vtiger_Viewer(); $viewer->assign('CURRENTDATE', Vtiger_Date_UIType::getDisplayDateValue(date('Y-n-j'))); $viewer->assign('MODULE', 'Home'); $viewer->assign('MODULE_NAME', 'Home'); $viewer->assign('QUALIFIED_MODULE', 'Home'); $viewer->assign('PARENT_MODULE', ''); $viewer->assign('VIEW', 'DashBoard'); $menuModelsList = Vtiger_Menu_Model::getAll(true); $menuStructure = Vtiger_MenuStructure_Model::getInstanceFromMenuList($menuModelsList, 'Home'); uksort($menuModelsList, array('Vtiger_MenuStructure_Model', 'sortMenuItemsByProcess')); $viewer->assign('SELECTED_MENU_CATEGORY', 'MARKETING'); $viewer->assign('SELECTED_MENU_CATEGORY_LABEL', 'Tableau de bord'); $viewer->assign('MENUS', $menuModelsList); $viewer->assign('QUICK_CREATE_MODULES', Vtiger_Menu_Model::getAllForQuickCreate()); $viewer->assign('MENU_STRUCTURE', $menuStructure); $viewer->assign('MENU_SELECTED_MODULENAME', 'Home'); $viewer->assign('MENU_TOPITEMS_LIMIT', $menuStructure->getLimit()); $viewer->assign('COMPANY_LOGO', Vtiger_CompanyDetails_Model::getInstanceById()->getLogo()); $viewer->assign('COMPANY_DETAILS_SETTINGS',new Settings_Vtiger_CompanyDetails_Model()); $viewer->assign('USER_MODEL', $current_user); $viewer->assign('CURRENT_USER_MODEL', $current_user); require_once 'libraries/csrf-magic/csrf-magic.php'; $viewer->assign('HOME_MODULE_MODEL', Vtiger_Module_Model::getInstance('Home')); $viewer->assign('HEADER_LINKS', Vtiger_Header_View::getHeaderLinks()); $viewer->assign('ANNOUNCEMENT', Vtiger_Header_View::getAnnouncement()); $viewer->assign('SEARCHABLE_MODULES', Vtiger_Module_Model::getSearchableModules()); $viewer->assign('INVENTORY_MODULES', getInventoryModules()); $viewer->assign('PAGETITLE','Réporting'); $viewer->assign('LANGUAGE_STRINGS', Vtiger_Language_Handler::export('Home', 'jsLanguageStrings')); $viewer->view('CustomDashboard.tpl'); $Reportings = array(); if(isset($_POST['Valider'])){ $NomWilaya = 'ALL'; $_SESSION['formulaireIDR'] = $_POST['formulaireID']; $Reportings = getReporting($_POST['formulaireID'] ,$NomWilaya); } if(isset($_POST['NomWilaya'])){ $NomWilaya= $_POST['NomWilaya']; $Reportings = getReporting($_SESSION['formulaireIDR'] ,$NomWilaya); } function result($Reporting , $AllChoix){ $type = explode("::",$Reporting['type_formulaire']); $Reporting['type_formulaire'] = $type[0]; if($Reporting['type_formulaire'] == "CHOIXMULTIPLES" or $Reporting['type_formulaire'] == "CHOIXUNIQUE" or $Reporting['type_formulaire'] == "PICKLISTGROSSISTE" or $Reporting['type_formulaire'] == "PARAGRAPHE"){ echo ' '.$Reporting['first_name']." ".$Reporting['last_name'].' '.$Reporting['accountname'].''; for ($d = 0; $d < sizeof($AllChoix); $d++) { $reponse ="reponse".$AllChoix[$d][0]; echo '
'.$Reporting[$reponse].'
'; } if($Reporting['type_formulaire'] == "CHOIXMULTIPLES" or $Reporting['type_formulaire'] == "CHOIXUNIQUE"){ echo ''.$Reporting['autres'].''; } echo ''; }else if($Reporting['type_formulaire'] == "POURCENTAGE" or $Reporting['type_formulaire'] == "NOMBRE"){ echo ' '.$Reporting['first_name']." ".$Reporting['last_name'].' '.$Reporting['accountname'].''; for ($m = 0; $m < sizeof($AllChoix); $m++) { $reponse ="reponse".$AllChoix[$m][0]; if(!empty($Reporting[$reponse])){ echo '
'.$Reporting[$reponse]; if($Reporting['type_formulaire'] == "POURCENTAGE") echo'%'; echo '
'; }else{ echo ''; } } if($Reporting['type_formulaire'] == "POURCENTAGE"){ echo ''.$Reporting['autres'].''; } echo ''; } } function getListeFormulaires(){ global $adb; $query = "SELECT * FROM `formulaire`"; $sql_get_result = $adb->query($query); $formulaire= array(); while ($recordinfo = $adb->fetch_array($sql_get_result)) { $formulaire[] = $recordinfo; } return $formulaire; } function getFormulaireQuestions($id_formulaire){ global $adb; $query = "SELECT id_ligne_formulaire , question FROM `lignes_formulaire` where id_formulaire = '".$id_formulaire."'"; $sql_get_result = $adb->query($query); $questions= array(); while ($recordinfo = $adb->fetch_array($sql_get_result)) { $questions[] = $recordinfo; } return $questions; } function getWilayas($id_formulaire){ global $adb; $query = "SELECT DISTINCT cf_992 FROM `result_lignes_formulaire` ,vtiger_accountscf WHERE id_ligne_formulaire = '".$id_formulaire."' and result_lignes_formulaire.accountId = vtiger_accountscf.accountid ORDER BY cf_992"; $sql_get_result = $adb->query($query); $wilayas= array(); while ($recordinfo = $adb->fetch_array($sql_get_result)) { $wilayas[] = $recordinfo; } return $wilayas; } function getReporting($id_formulaire , $wilaya){ global $adb; if($wilaya == "ALL"){ $sql = ""; }else{ $sql =" and vtiger_accountscf.cf_992 = '".$wilaya."'" ; } $query = "SELECT * FROM lignes_formulaire , result_lignes_formulaire , vtiger_account , vtiger_users, vtiger_accountscf where lignes_formulaire.id_ligne_formulaire = '".$id_formulaire."' and lignes_formulaire.id_ligne_formulaire = result_lignes_formulaire.id_ligne_formulaire and result_lignes_formulaire.accountId = vtiger_account.accountid and vtiger_users.id = result_lignes_formulaire.user_id and vtiger_account.accountid = vtiger_accountscf.accountid".$sql; $sql_get_result = $adb->query($query); $Reporting= array(); while ($recordinfo = $adb->fetch_array($sql_get_result)) { $Reporting[] = $recordinfo; } return $Reporting; } function getSumAccount($id_formulaire){ global $adb; $query = "SELECT COUNT(id) as sum FROM `result_lignes_formulaire` WHERE id_ligne_formulaire = '".$id_formulaire."'"; $sql_get_result = $adb->query($query); $sum= array(); while ($recordinfo = $adb->fetch_array($sql_get_result)) { $sum[] = $recordinfo; } return $sum[0]['sum']; } function DataForPie($AllChoix , $type , $id_formulaire , $wilaya){ global $adb; if($wilaya == "ALL"){ $sql = ""; }else{ $sql =" and vtiger_accountscf.cf_992 = '".$wilaya."'" ; } if($type == "POURCENTAGE" OR $type == "NOMBRE"){ $query = "SELECT sum(CAST(`reponse1` as decimal(10))) as reponse1 , sum(CAST(`reponse2` as decimal(10))) as reponse2 , sum(CAST(`reponse3` as decimal(10))) as reponse3 , sum(CAST(`reponse4` as decimal(10))) as reponse4 , sum(CAST(`reponse5` as decimal(10))) as reponse5 , sum(CAST(`reponse6` as decimal(10))) as reponse6 , sum(CAST(`reponse7` as decimal(10))) as reponse7, sum(CAST(`reponse8` as decimal(10))) as reponse8 , sum(CAST(`reponse9` as decimal(10))) as reponse9 , sum(CAST(`reponse10` as decimal(10))) as reponse10 FROM `result_lignes_formulaire` ,vtiger_accountscf WHERE id_ligne_formulaire = '".$id_formulaire."' and result_lignes_formulaire.accountId = vtiger_accountscf.accountid ".$sql; }else if($type == "CHOIXMULTIPLES" or $type =='CHOIXUNIQUE' or $type =='PICKLISTGROSSISTE'){ $query ="SELECT sum(IF(LENGTH(reponse1), 1, 0)) as reponse1, sum(IF(LENGTH(reponse2), 1, 0)) as reponse2, sum(IF(LENGTH(reponse3), 1, 0)) as reponse3, sum(IF(LENGTH(reponse4), 1, 0)) as reponse4, sum(IF(LENGTH(reponse5), 1, 0)) as reponse5, sum(IF(LENGTH(reponse6), 1, 0)) as reponse6, sum(IF(LENGTH(reponse7), 1, 0)) as reponse7, sum(IF(LENGTH(reponse8), 1, 0)) as reponse8, sum(IF(LENGTH(reponse9), 1, 0)) as reponse9, sum(IF(LENGTH(reponse10), 1, 0)) as reponse10 FROM `result_lignes_formulaire` ,vtiger_accountscf WHERE id_ligne_formulaire = '".$id_formulaire."' and result_lignes_formulaire.accountId = vtiger_accountscf.accountid ".$sql; } $sql_get_result = $adb->query($query); $Data= array(); while ($recordinfo = $adb->fetch_array($sql_get_result)) { $Data[] = $recordinfo; } $dataPie=array(); $dataPieFinal =array(); for ($m = 0; $m < sizeof($AllChoix); $m++) { $reponse ="reponse".$AllChoix[$m][0]; array_push($dataPie,array(' '.$AllChoix[$m][1].' ', ($Data[0][$reponse]/getSumAccount($id_formulaire)) )); } array_push($dataPieFinal,$dataPie); //print("
".print_r($dataPieFinal,true)."
"); return $dataPieFinal; } echo '
'; if(!empty($Reportings) && isset($Reportings)){ echo'

'.$Reportings[0]['question'].'


'; $AllChoix=array(); for ($y = 1; $y <= 10; $y++) { $choix ="choix".$y; if(trim($Reportings[0][$choix ]) != ''){ array_push($AllChoix,array($y,$Reportings[0][$choix])); echo''; } } if($Reportings[0]['type_formulaire'] == "CHOIXMULTIPLES" or $Reportings[0]['type_formulaire'] == "CHOIXUNIQUE" or $Reportings[0]['type_formulaire'] == "POURCENTAGE"){ echo ' '; } echo' '; $NbrComptes=0; foreach ($Reportings as $Reporting) { result($Reporting , $AllChoix); $NbrComptes++; } echo '
Assigné à
Compte
  '.$Reportings[0][$choix].'
Commentaire
Total : '.$NbrComptes.'
'; if(sizeof($AllChoix) > 1 ){ $type = explode("::",$Reporting['type_formulaire']); $Reporting['type_formulaire'] = $type[0]; if($Reporting['type_formulaire'] != "PICKLISTGROSSISTE" and $Reporting['type_formulaire'] != "PARAGRAPHE" ){ echo'
'; $data = DataForPie($AllChoix , $Reportings[0]['type_formulaire'] , $Reportings[0]['id_ligne_formulaire'] ,$NomWilaya); //print("
".print_r($AllChoix,true)."
"); } } } echo'
'; $viewer->view('CustomDashboardFooter.tpl'); ?>