diff --git a/.gitignore b/.gitignore
index 75c1b56c..b06f6636 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,17 @@
-/test
-/logs
-/user_privileges
-*.log
-*.bak
\ No newline at end of file
+/test
+
+/logs
+
+/user_privileges
+
+*.log
+
+*.bak
+
+test/templates_c/
+test/templates_c/*.tpl.php
+test/templates_c/v7/710e620183d7eba30794adcdaa65a6b9b5aba915.file.Footer.tpl.php
+test/templates_c/v7/833e7fc50cbf769ba11253f5188fa344a967b92e.file.SidebarAppMenu.tpl.php
+test/templates_c/v7/2627944103942efed50bd439d9d1dbdcc67dc480.file.ModalFooter.tpl.php
+test/templates_c/v7/b62713acd22803ca6b3ad6d54ce71cdbcc4dc22a.file.Topbar.tpl.php
+test/templates_c/v7/b307425d1b338e6a92e5cdf7e1d4fa12929b2d14.file.Multireference.tpl.php
diff --git a/DashBoardAjax.php b/DashBoardAjax.php
index e25811a7..80f544d3 100644
--- a/DashBoardAjax.php
+++ b/DashBoardAjax.php
@@ -234,7 +234,9 @@
LEFT JOIN vtiger_accountscf ON (vtiger_accountscf.accountid =vtiger_account.accountid)
- WHERE vtiger_account.industry = '{$type}' and vtiger_accountscf.cf_990 <> ''
+ INNER JOIN vtiger_crmentity ON vtiger_account.accountid = vtiger_crmentity.crmid
+
+ WHERE vtiger_account.industry = '{$type}' and vtiger_accountscf.cf_990 <> '' and vtiger_crmentity.deleted = 0
GROUP by vtiger_accountscf.cf_990 ORDER BY `region` ASC";
diff --git a/DashBoardAll.php b/DashBoardAll.php
index 04b37a52..ddc491d1 100644
--- a/DashBoardAll.php
+++ b/DashBoardAll.php
@@ -1932,11 +1932,33 @@ function box(data) {
success: function (data) {
- //console.log(data);
+ let cleanData = data.trim();
+
+ data = data.replace('{', '{');
- data = data.replace('{', '{');
+ console.log(data);
- var dataResult = JSON.parse(data);
+ // Remove anything starting from the first
diff --git a/ExportTable.php b/ExportTable.php
index d0b5ff8b..5c74be39 100644
--- a/ExportTable.php
+++ b/ExportTable.php
@@ -1,129 +1,273 @@
- $value){
- array_push($filter,$value);
- };
-
- $user_query = 'select * from '.$table;
- $result =$adb->query($user_query);
-
- ob_clean();
- header('Pragma: public');
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Cache-Control: private', false);
- header('Content-Type: text/csv; charset=utf-8');
- header('Content-Disposition: attachment;filename=' . $fileName);
-
-
- $fp = fopen('php://output', 'w');
-
- while ($row = $adb->fetchByAssoc($result)) {
- if (!$flag) {
- // display field/column names as first row
- fputcsv($fp, array_keys($row),';');
- $flag = true;
- }
-
- if(isMedicalSuperviseur($roleid)){
- if(in_array($row['visiteur'],$filter)){
- $csv_values = array_map('decode_html', array_values($row));
- fputcsv($fp, $csv_values,';');
- }
- }
- else{
- $csv_values = array_map('decode_html', array_values($row));
- fputcsv($fp, $csv_values,';');
- }
- }
- fclose($fp);
- ob_flush();
- die;
-}
-
-
-/* ancien code lakheder ben
-if(isset($_GET['table'])){
- $table = $_GET['table'];
-}
-
-$extension = ".xls";//".csv";
-if(isset($_GET['xls']) && $_GET['xls'] == true)
- $extension = ".xls";
-global $adb;
-$filename = "Data_".$table.$extension; // File Name
-// Download file
-header("Content-Disposition: attachment; filename=\"$filename\"");
-header("Content-Type: application/vnd.ms-excel");
-$user_query = 'select * from '.$table;
-$result =$adb->query($user_query);
-// Write data to file
-$flag = false;
-ob_end_clean();
-ob_start();
-while ($row = $adb->fetch_array($result)) {
- unset($row['0']);
- unset($row['1']);
- unset($row['2']);
- unset($row['3']);
- unset($row['4']);
- unset($row['5']);
- unset($row['6']);
- unset($row['7']);
- unset($row['8']);
- unset($row['9']);
- unset($row['10']);
- unset($row['11']);
- unset($row['12']);
- unset($row['13']);
- unset($row['14']);
- unset($row['15']);
- unset($row['16']);
- unset($row['17']);
- unset($row['18']);
- unset($row['19']);
- unset($row['20']);
- unset($row['21']);
- if (!$flag) {
- // display field/column names as first row
- echo implode("\t", array_keys($row)) . "\r\n";
- $flag = true;
- }
-
- $temp = implode("\t", array_values($row));
- $temp = str_replace("'", " ", $temp);
- $temp = str_replace("’", " ", $temp);
- $temp = str_replace("ç", "c", $temp);
- $temp = str_replace("â", "a", $temp);
- $temp = str_replace("è", "e", $temp);
- $temp = str_replace('é', 'e', $temp);
- $temp = str_replace('ï', 'e', $temp);
- $temp = str_replace('Ï', 'i', $temp);
- $temp = str_replace('É', 'E', $temp);
- $temp = str_replace(' ', "", $temp);
- $temp = str_replace('ô', "o", $temp);
- $temp = str_replace(array("\r", "\n"), '', $temp);
- //preg_replace( "/\r|\n/", "", $temp );
- echo str_replace('.', ',', $temp)."\r\n";
-}
-*/
+retrieveCurrentUserInfoFromFile($_SESSION['authenticated_user_id']);
+ $roleid = $current_user->roleid;
+} else {
+ echo "Access denied. Not logged in.";
+ exit;
+}
+
+
+if(isset($_GET['table'])){
+
+ $table = $_GET['table'];
+
+ $current_user = new Users();
+ $current_user->retrieveCurrentUserInfoFromFile($_SESSION['authenticated_user_id']);
+ $roleid = $current_user->roleid;
+
+ $filename = "Data_".$table.".csv";
+
+ outputCsv($filename,$table,$roleid);
+
+}
+
+
+
+function outputCsv($fileName,$table,$roleid)
+
+{
+
+ global $adb;
+
+
+
+ $filter = [];
+
+ $sub = (getMySubordinates($roleid));
+
+ $flag = false;
+
+ foreach($sub as $key => $value){
+
+ array_push($filter,$value);
+
+ };
+
+
+
+ $user_query = 'select * from '.$table;
+
+
+ if ($roleid == 'H34' || $roleid == 'H36' || $roleid == 'H38' || $roleid == 'H42' || $roleid == 'H44') {
+ $user_query = "SELECT * FROM `$table` WHERE parentrole LIKE '%::$roleid::%' OR parentrole = '$roleid'";
+ }
+
+ $result =$adb->query($user_query);
+
+
+
+ ob_clean();
+
+ header('Pragma: public');
+
+ header('Expires: 0');
+
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+
+ header('Cache-Control: private', false);
+
+ header('Content-Type: text/csv; charset=utf-8');
+
+ header('Content-Disposition: attachment;filename=' . $fileName);
+
+
+
+
+
+ $fp = fopen('php://output', 'w');
+
+
+
+ while ($row = $adb->fetchByAssoc($result)) {
+
+ if (!$flag) {
+
+ // display field/column names as first row
+
+ fputcsv($fp, array_keys($row),';');
+
+ $flag = true;
+
+ }
+
+
+
+ // if(isMedicalSuperviseur($roleid)){
+
+ // if (in_array($row['visiteur1'], $filter) || in_array($row['visiteur2'], $filter) || in_array($row['visiteur3'], $filter) || in_array($row['visiteur3'], $filter)) {
+
+ // $csv_values = array_map('decode_html', array_values($row));
+
+ // fputcsv($fp, $csv_values,';');
+
+ // }
+
+ // }
+
+ // else{
+
+ $csv_values = array_map('decode_html', array_values($row));
+
+ fputcsv($fp, $csv_values,';');
+
+ // }
+
+ }
+
+ fclose($fp);
+
+ ob_flush();
+
+ die;
+
+}
+
+
+
+
+
+/* ancien code lakheder ben
+
+if(isset($_GET['table'])){
+
+ $table = $_GET['table'];
+
+}
+
+
+
+$extension = ".xls";//".csv";
+
+if(isset($_GET['xls']) && $_GET['xls'] == true)
+
+ $extension = ".xls";
+
+global $adb;
+
+$filename = "Data_".$table.$extension; // File Name
+
+// Download file
+
+header("Content-Disposition: attachment; filename=\"$filename\"");
+
+header("Content-Type: application/vnd.ms-excel");
+
+$user_query = 'select * from '.$table;
+
+$result =$adb->query($user_query);
+
+// Write data to file
+
+$flag = false;
+
+ob_end_clean();
+
+ob_start();
+
+while ($row = $adb->fetch_array($result)) {
+
+ unset($row['0']);
+
+ unset($row['1']);
+
+ unset($row['2']);
+
+ unset($row['3']);
+
+ unset($row['4']);
+
+ unset($row['5']);
+
+ unset($row['6']);
+
+ unset($row['7']);
+
+ unset($row['8']);
+
+ unset($row['9']);
+
+ unset($row['10']);
+
+ unset($row['11']);
+
+ unset($row['12']);
+
+ unset($row['13']);
+
+ unset($row['14']);
+
+ unset($row['15']);
+
+ unset($row['16']);
+
+ unset($row['17']);
+
+ unset($row['18']);
+
+ unset($row['19']);
+
+ unset($row['20']);
+
+ unset($row['21']);
+
+ if (!$flag) {
+
+ // display field/column names as first row
+
+ echo implode("\t", array_keys($row)) . "\r\n";
+
+ $flag = true;
+
+ }
+
+
+
+ $temp = implode("\t", array_values($row));
+
+ $temp = str_replace("'", " ", $temp);
+
+ $temp = str_replace("’", " ", $temp);
+
+ $temp = str_replace("ç", "c", $temp);
+
+ $temp = str_replace("â", "a", $temp);
+
+ $temp = str_replace("è", "e", $temp);
+
+ $temp = str_replace('é', 'e', $temp);
+
+ $temp = str_replace('ï', 'e', $temp);
+
+ $temp = str_replace('Ï', 'i', $temp);
+
+ $temp = str_replace('É', 'E', $temp);
+
+ $temp = str_replace(' ', "", $temp);
+
+ $temp = str_replace('ô', "o", $temp);
+
+ $temp = str_replace(array("\r", "\n"), '', $temp);
+
+ //preg_replace( "/\r|\n/", "", $temp );
+
+ echo str_replace('.', ',', $temp)."\r\n";
+
+}
+
+*/
+
?>
\ No newline at end of file
diff --git a/MonitoringVMHeader.php b/MonitoringVMHeader.php
index 1211f2fe..26535620 100644
--- a/MonitoringVMHeader.php
+++ b/MonitoringVMHeader.php
@@ -232,6 +232,8 @@ $viewer->view('CustomDashboard.tpl');
$active8 = "";
+ $active9 = "";
+
if($active == 1) $active1 = 'active';
if($active == 2) $active2 = 'active';
@@ -248,6 +250,10 @@ $viewer->view('CustomDashboard.tpl');
if($active == 8) $active8 = 'active';
+ if($active == 9) $active9 = 'active';
+
+ if($active == 10) $active10 = 'active';
+
return '
diff --git a/PTGeneration.php b/PTGeneration.php
index 4a5add44..a58c1ca0 100644
--- a/PTGeneration.php
+++ b/PTGeneration.php
@@ -215,8 +215,8 @@ if(isset($_POST['comptes']) && isset($_POST['date'])) {
}
else if (isMedecin($roleid)){
- $query = $query." WHERE ((e.smownerid like ? OR `vm2_id` like ? OR `vm3_id` like ?) AND e.deleted = 0 AND cf.cf_994 like ? ";
- $query = $query." AND a.industry ='Medecin') or (a.industry ='Pharmacie' AND cf.cf_994 like '{$communep}')";
+ $query = $query." WHERE ((e.smownerid like ? OR `vm2_id` like ? OR `vm3_id` like ?)AND cf.cf_994 like ? ";
+ $query = $query." AND a.industry ='Medecin') or (a.industry ='Pharmacie' AND cf.cf_994 like '{$communep}') AND e.deleted = 0 ";
$result = $adb->pquery($query, array($userId, $userId, $userId, $communep));
}
@@ -231,8 +231,8 @@ if(isset($_POST['comptes']) && isset($_POST['date'])) {
else if (isMedecin($roleid)){
- $query = $query." WHERE ((e.smownerid like ? OR `vm2_id` like ? OR `vm3_id` like ?) AND e.deleted = 0 AND cf.cf_996 like ? ";
- $query = $query." AND a.industry ='Medecin') or (a.industry ='Pharmacie' AND cf.cf_996 like '{$brickp}')";
+ $query = $query." WHERE ((e.smownerid like ? OR `vm2_id` like ? OR `vm3_id` like ?) AND cf.cf_996 like ? ";
+ $query = $query." AND a.industry ='Medecin') or (a.industry ='Pharmacie' AND cf.cf_996 like '{$brickp}') AND e.deleted = 0 ";
$result = $adb->pquery($query, array($userId, $userId, $userId, $brickp));
}
diff --git a/PharmexObjective.php b/PharmexObjective.php
new file mode 100644
index 00000000..4884d24a
--- /dev/null
+++ b/PharmexObjective.php
@@ -0,0 +1,932 @@
+
+get('id');
+$event = $_GET["event"];
+$objective = 0;
+
+if (!isVPSuperviseur($roleid) && !isTopDG($roleid) && !isResponsableCommercial($roleid)) {
+ die(" Vous n'êtes pas autorisé à lire cette ressource.
");
+}
+
+if (isTopDG($roleid)) {
+ $roleid = "H10";
+}
+// $datedeb = date("Y-m-d", strtotime("-1 month"));
+// $datefin = date('Y-m-d');
+
+$datedeb = '2026-11-04';
+$datefin = '2026-11-30';
+
+if ($event == "Saidalya") {
+ $datedeb = '2026-02-04';
+ $datefin = '2026-02-07';
+ $objective = 300000000.00; // Objective value (0-100)
+ echo getMonitoringMainBarVP(9);
+} else if ($event == "November") {
+ $datedeb = '2026-01-13';
+ $datefin = '2026-02-15';
+ $objective = 500000000.00; // Objective value (0-100)
+
+ echo getMonitoringMainBarVP(10);
+} else {
+ die("Unauthorized");
+}
+
+$vpFilter = "";
+
+if ($event == "Saidalya") {
+ $vpFilter = " AND us.id IN (156,125,215,137,149,261,127,124,43,254,212,255,253,186,248,222)";
+}
+
+$currentValue = 0; // Current gauge value (0-100)
+
+?>
+
+
+ 1
+ JOIN vtiger_salesorder so ON so.salesorderid = crm.crmid
+ JOIN vtiger_accountscf acf ON acf.accountid = so.accountid";
+$queryCA = $queryCA . " WHERE so.duedate BETWEEN '" . $datedeb . "' and '" . $datefin . "' $vpFilter order by total_bc asc";
+$queryCA = $queryCA . ") AS subquery order by total_bc desc; ";
+
+$sql_get_result_ca = $adb->query($queryCA);
+$result_ca = array();
+while ($recordinfo = $adb->fetch_array($sql_get_result_ca)) {
+ $result_ca[] = $recordinfo;
+}
+$currentValue = $result_ca[0][0] ?? 0;
+
+
+// CA Par Client
+$query = "SELECT soc.cf_854 as accountname,
+ sum(so.subtotal) as totalmargin
+ FROM `vtiger_salesorder` so
+ JOIN vtiger_salesordercf soc on soc.salesorderid = so.salesorderid
+ JOIN vtiger_crmentity e on so.`salesorderid` = e.crmid and e.deleted <> 1 and e.setype='SalesOrder'
+ JOIN vtiger_users us on us.id = e.smownerid and us.status <> 'Inactive'
+ JOIN vtiger_user2role usr ON usr.userid = us.id
+ JOIN vtiger_role ro ON ro.roleid = usr.roleid";
+$query = $query . " WHERE so.duedate BETWEEN '" . $datedeb . "' and '" . $datefin . "' $vpFilter";
+$query = $query . " GROUP by accountname order by totalmargin desc";
+$sql_get_result_client = $adb->query($query);
+$result_client = array();
+while ($recordinfo = $adb->fetch_array($sql_get_result_client)) {
+ $result_client[] = $recordinfo;
+}
+$json_data = json_encode($result_client);
+
+
+// Par produit
+$query_produit = "SELECT p.productname, sum(ip.quantity) as totalquantity , sum(ip.margin) as totalmargin
+ FROM `vtiger_salesorder` so
+ JOIN vtiger_inventoryproductrel ip on so.`salesorderid` = ip.id
+ JOIN vtiger_crmentity e on so.`salesorderid` = e.crmid and e.deleted = 0
+ JOIN vtiger_products p on p.productid = ip.productid
+ JOIN vtiger_users us on us.id = e.smownerid and us.status <> 'Inactive'
+ JOIN vtiger_user2role usr ON usr.userid = us.id
+ JOIN vtiger_role ro ON ro.roleid = usr.roleid";
+$query_produit = $query_produit . " WHERE so.duedate BETWEEN '" . $datedeb . "' and '" . $datefin . "' $vpFilter";
+$query_produit = $query_produit . " GROUP by p.productname order by totalmargin desc"; //, month , year";
+
+
+$sql_get_result_product = $adb->query($query_produit);
+$result_products_arr = array();
+while ($recordinfo = $adb->fetch_array($sql_get_result_product)) {
+ $result_products_arr[] = $recordinfo;
+}
+
+$result_products = json_encode($result_products_arr);
+// $totalMargins = array_column($result_products, 'totalmargin');
+
+
+// PAR VP
+$query_vp = "SELECT
+ fullname,
+ total_bc AS bc
+ FROM
+ (SELECT us.id,CONCAT(first_name, ' ', last_name) AS fullname,SUM(subtotal) AS total_bc
+ FROM vtiger_users us JOIN vtiger_user2role usr ON usr.userid = us.id
+ JOIN vtiger_crmentity crm ON crm.smownerid = us.id AND crm.setype = 'SalesOrder' AND crm.deleted <> 1
+ JOIN vtiger_salesorder so ON so.salesorderid = crm.crmid ";
+$query_vp = $query_vp . " WHERE so.duedate BETWEEN '" . $datedeb . "' and '" . $datefin . "' $vpFilter";
+$query_vp = $query_vp . " GROUP BY us.id,fullname) as s ";
+
+$sql_get_result_vp = $adb->query($query_vp);
+$result_vp = array();
+while ($recordinfo = $adb->fetch_array($sql_get_result_vp)) {
+ $result_vp[] = $recordinfo;
+}
+
+$result_vp = json_encode($result_vp);
+
+
+// echo "";
+// print_r($result_products);
+// echo " ";
+// // print_r($productNames);
+// echo $result_vp;
+// die();
+
+?>
+
+
+
+
+
+
+
+
+ Dashboard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
CA % Objectif ()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Répartition Marge Totale (Top 10 Produits)
+
+
+
+
+
+
+
Répartition Quantité Totale (Top 10 Produits - Pie Chart)
+
+
+
+
+
+
+
Marge par client
+
+
+
+
+
+
+
Répartition CA par VP (Top 10)
+
+
+
+
+
+
+
+
+
+
CA par Client
+
+
+
+
+ Client
+ Marge Totale (D.A)
+
+
+
+
+
+ = htmlspecialchars($row['accountname']) ?>
+ = $row['totalmargin'] ?>
+
+
+
+
+
+
+
+
+
+
+
+
Produits : Quantité & Marge Totale
+
+
+
+
+ Produit
+ Quantité Totale
+ Marge Totale (D.A)
+
+
+
+
+
+ = htmlspecialchars($row['productname']) ?>
+ = $row['totalquantity'] ?>
+ = $row['totalmargin'] ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SUtiles.php b/SUtiles.php
index 465c3e4c..475d8296 100644
--- a/SUtiles.php
+++ b/SUtiles.php
@@ -1,176 +1,364 @@
-$userids) {
- foreach($userids as $roleid2=>$userids2) {
- if($owuserid == $roleid2 || $vm2 == $roleid2 || $vm3 == $roleid2)
- return true;
- }
- }
- return false;
- }
-
- function isByWilaya($id) {
- return $id == '113';
- }
-
- function isOuestVMVP($roleid) {
- return $roleid=="H9" || $roleid=="H31" || $roleid=="H3" || $roleid=="H19" || $roleid=="H18" || $roleid=="H17" || $roleid=="H7" || $roleid=="H4" || $roleid=="H36" ; //(H7,H4,H36 VP)
- }
-
- function isEstVMVP($roleid) {
- return $roleid=="H28" || $roleid=="H29" || $roleid=="H27" || $roleid=="H24" || $roleid=="H25" || $roleid=="H26" || $roleid=="H15" || $roleid=="H12" || $roleid=="H13" || $roleid=="H34" || $roleid=="H35" || $roleid=="H42" || $roleid == "H43"; //(H12,H13,H34,H35 VP)
- }
-
- function isCentreVMVP($roleid) {
- return $roleid=="H16" || $roleid=="H20" || $roleid=="H21" || $roleid == 'H39' || $roleid=="H22" || $roleid=="H23" || $roleid=="H30" || $roleid=="H11" || $roleid=="H14" || $roleid == "H44" || $roleid=="H45"; //(H11,H14 VP)
- }
-
- function isSuperviseur($role) {
- return $role=="SUPERVISEUR MEDICAL EST1" || $role=="SUPERVISEUR MEDICAL EST2" || $role=="SUPERVISEUR MEDICAL EST3" ||
- $role=="SUPERVISEUR MEDICAL CENTRE1" || $role=="SUPERVISEUR MEDICAL CENTRE2" || $role=="SUPERVISEUR MEDICAL CENTRE3" ||
- $role=="SUPERVISEUR MEDICAL OUEST1" || $role=="SUPERVISEUR MEDICAL OUEST2";
- }
-
- function isMedicalSuperviseur($roleid) {
- return $roleid == 'H17' || $roleid == 'H18' || $roleid == 'H20' || $roleid == 'H21' || $roleid == 'H24' || $roleid == 'H25' || $roleid == 'H26' || $roleid == 'H39';
- }
-
- function isDM($role) {
- return $role=="DELEGUE MEDICAL EST1" || $role=="DELEGUE MEDICAL EST2" || $role=="DELEGUE MEDICAL EST3" ||
- $role=="DELEGUE MEDICAL CENTRE1" || $role=="DELEGUE MEDICAL CENTRE2" || $role=="DELEGUE MEDICAL CENTRE3" ||
- $role=="DELEGUE MEDICAL OUEST1" || $role=="DELEGUE MEDICAL OUEST2" || $role=="DELEGUE MEDICAL OUEST";
- }
-
- function isOuestVMText($role) {
- return $role=="DIRECTEUR REGIONAL OUEST" || $role=="SUPERVISEUR MEDICAL OUEST1" || $role=="DELEGUE MEDICAL OUEST1"
- || $role=="SUPERVISEUR MEDICAL OUEST2" || $role=="DELEGUE MEDICAL OUEST2" || $role=="DELEGUE MEDICAL OUEST";
- }
-
- function isCentreVMText($role) {
- return $role=="DIRECTEUR REGIONAL CENTRE" || $role=="SUPERVISEUR MEDICAL CENTRE1" || $role=="DELEGUE MEDICAL CENTRE1"
- || $role=="SUPERVISEUR MEDICAL CENTRE2" || $role=="DELEGUE MEDICAL CENTRE2" || $role=="DELEGUE MEDICAL CENTRE3" || $role=="SUPERVISEUR MEDICAL CENTRE3";
- }
-
- function isEstVMText($role) {
- return $role=="DIRECTEUR REGIONAL EST" || $role=="SUPERVISEUR MEDICAL EST1" || $role=="DELEGUE MEDICAL EST1"
- || $role=="SUPERVISEUR MEDICAL EST2" || $role=="DELEGUE MEDICAL EST2" || $role=="SUPERVISEUR MEDICAL EST3" || $role=="DELEGUE MEDICAL EST3";
- }
-
- function isKAM($role) {
- return $role=="KEY ACCOUNT MANAGER CENTRE" || $role=="KEY ACCOUNT MANAGER EST" || $role=="KEY ACCOUNT MANAGER OUEST";
- }
-
- function isVPText($role) {
- return $role=="DELEGUE COMMERCIAL EST" || $role=="DELEGUE COMMERCIAL EST2" || $role=="DELEGUE COMMERCIAL CENTRE" || $role=="DELEGUE COMMERCIAL OUEST";
- }
-
- function isOuestVPText($role) {
- return $role=="KEY ACCOUNT MANAGER OUEST" || $role=="DELEGUE COMMERCIAL OUEST";
- }
-
- function isCentreVPText($role) {
- return $role=="KEY ACCOUNT MANAGER CENTRE" || $role=="DELEGUE COMMERCIAL CENTRE";
- }
-
- function isEstVPText($role) {
- return $role=="KEY ACCOUNT MANAGER EST" || $role=="DELEGUE COMMERCIAL EST" || $role=="DELEGUE COMMERCIAL EST2";
- }
-
- function showNewDashBoard($userID) {
-
- require_once 'include/utils/GetGroupUsers.php';
- $userGroups_DB = new GetGroupUsers();
- //145 id group
- $userGroups_DB->getAllUsersInGroup(145);
- $GetGroupUsers_DB = $userGroups_DB->group_users;
- $is = in_array($userID, $GetGroupUsers_DB);
- if($is == true){
- return true;
- }
-
-
- return false;
- }
-
- //note de frais admin
- function isAdminNdf($userId){
- global $adb;
-
- $query = "SELECT id_validateur_2 FROM note_de_frais_parametres";
- $sql_get_result = $adb->query($query);
- $res= array();
-
- while ($recordinfo = $adb->fetch_array($sql_get_result)) {
- $res[] = $recordinfo;
- }
-
- if( $userId == 1 || $userId == $res[0]['id_validateur_2']){
- return true;
- }
-
- return false;
- }
-
- function generatePassword($user_name, $crypt_type) {
-
- $password = makeRandomPassword();
-
- $salt = substr($user_name, 0, 2);
- $salt = '$1$' . str_pad($salt, 9, '0');
- $enc_password = crypt($password, $salt);
-
- $user_hash = strtolower(md5($password));
-
- return [$enc_password, $user_hash, $password];
- }
-
-?>
-
-
+$userids) {
+
+ foreach($userids as $roleid2=>$userids2) {
+
+ if($owuserid == $roleid2 || $vm2 == $roleid2 || $vm3 == $roleid2)
+
+ return true;
+
+ }
+
+ }
+
+ return false;
+
+}
+
+
+
+function isByWilaya($id) {
+
+ return $id == '26' || $id == '48' || $id == '51' || $id == '125' || $id == '126' || $id == '130' || $id == '152' || $id == '46' || $id == '47' || $id == '49' || $id == '50' || $id == '52' || $id == '53' || $id == '104' || $id == '128' || $id == '131' || $id == '135' || $id == '136' || $id == '150' || $id == '153' || $id == '154' || $id == '186' || $id == '217' || $id == '44' || $id == '54' || $id == '55' || $id == '43' || $id == '124' || $id == '143' || $id == '158' || $id == '181' || $id == '254' || $id == '259' || $id == '134' || $id == '137' || $id == '149' || $id == '184' || $id == '187' || $id == '248' || $id == '253' || $id == '255' || $id == '38' || $id == '39' || $id == '40' || $id == '41' || $id == '42' || $id == '112' || $id == '113' || $id == '123' || $id == '127' || $id == '200' || $id == '201' || $id == '212' || $id == '216';
+}
+
+
+
+function isOuestVMVP($roleid) {
+
+ return $roleid=="H9" || $roleid=="H31" || $roleid=="H3" || $roleid=="H19" || $roleid=="H18" || $roleid=="H17" || $roleid=="H7" || $roleid=="H4" || $roleid=="H36" ; //(H7,H4,H36 VP)
+
+}
+
+
+
+function isEstVMVP($roleid) {
+
+ return $roleid=="H28" || $roleid=="H29" || $roleid=="H27" || $roleid=="H24" || $roleid=="H25" || $roleid=="H26" || $roleid=="H15" || $roleid=="H12" || $roleid=="H13" || $roleid=="H34" || $roleid=="H35" || $roleid=="H42" || $roleid == "H43"; //(H12,H13,H34,H35 VP)
+
+}
+
+
+
+function isCentreVMVP($roleid) {
+
+ return $roleid=="H16" || $roleid=="H20" || $roleid=="H21" || $roleid == 'H39' || $roleid=="H22" || $roleid=="H23" || $roleid=="H30" || $roleid=="H11" || $roleid=="H14" || $roleid == "H44" || $roleid=="H45"; //(H11,H14 VP)
+
+}
+
+
+
+function isSuperviseur($role) {
+
+ return $role=="SUPERVISEUR MEDICAL EST1" || $role=="SUPERVISEUR MEDICAL EST2" || $role=="SUPERVISEUR MEDICAL EST3" ||
+
+ $role=="SUPERVISEUR MEDICAL CENTRE1" || $role=="SUPERVISEUR MEDICAL CENTRE2" || $role=="SUPERVISEUR MEDICAL CENTRE3" ||
+
+ $role=="SUPERVISEUR MEDICAL OUEST1" || $role=="SUPERVISEUR MEDICAL OUEST2";
+
+}
+
+
+
+function isMedicalSuperviseur($roleid) {
+
+ return $roleid == 'H17' || $roleid == 'H18' || $roleid == 'H20' || $roleid == 'H21' || $roleid == 'H24' || $roleid == 'H25' || $roleid == 'H26' || $roleid == 'H39';
+
+}
+
+
+
+function isDM($role) {
+
+ return $role=="DELEGUE MEDICAL EST1" || $role=="DELEGUE MEDICAL EST2" || $role=="DELEGUE MEDICAL EST3" ||
+
+ $role=="DELEGUE MEDICAL CENTRE1" || $role=="DELEGUE MEDICAL CENTRE2" || $role=="DELEGUE MEDICAL CENTRE3" ||
+
+ $role=="DELEGUE MEDICAL OUEST1" || $role=="DELEGUE MEDICAL OUEST2" || $role=="DELEGUE MEDICAL OUEST";
+
+}
+
+
+
+function isOuestVMText($role) {
+
+ return $role=="DIRECTEUR REGIONAL OUEST" || $role=="SUPERVISEUR MEDICAL OUEST1" || $role=="DELEGUE MEDICAL OUEST1"
+
+ || $role=="SUPERVISEUR MEDICAL OUEST2" || $role=="DELEGUE MEDICAL OUEST2" || $role=="DELEGUE MEDICAL OUEST";
+
+}
+
+
+
+function isCentreVMText($role) {
+
+ return $role=="DIRECTEUR REGIONAL CENTRE" || $role=="SUPERVISEUR MEDICAL CENTRE1" || $role=="DELEGUE MEDICAL CENTRE1"
+
+ || $role=="SUPERVISEUR MEDICAL CENTRE2" || $role=="DELEGUE MEDICAL CENTRE2" || $role=="DELEGUE MEDICAL CENTRE3" || $role=="SUPERVISEUR MEDICAL CENTRE3";
+
+}
+
+
+
+function isEstVMText($role) {
+
+ return $role=="DIRECTEUR REGIONAL EST" || $role=="SUPERVISEUR MEDICAL EST1" || $role=="DELEGUE MEDICAL EST1"
+
+ || $role=="SUPERVISEUR MEDICAL EST2" || $role=="DELEGUE MEDICAL EST2" || $role=="SUPERVISEUR MEDICAL EST3" || $role=="DELEGUE MEDICAL EST3";
+
+}
+
+
+
+function isKAM($role) {
+
+ return $role=="KEY ACCOUNT MANAGER CENTRE" || $role=="KEY ACCOUNT MANAGER EST" || $role=="KEY ACCOUNT MANAGER OUEST";
+
+}
+
+
+
+function isVPText($role) {
+
+ return $role=="DELEGUE COMMERCIAL EST" || $role=="DELEGUE COMMERCIAL EST2" || $role=="DELEGUE COMMERCIAL CENTRE" || $role=="DELEGUE COMMERCIAL OUEST";
+
+}
+
+
+
+function isOuestVPText($role) {
+
+ return $role=="KEY ACCOUNT MANAGER OUEST" || $role=="DELEGUE COMMERCIAL OUEST";
+
+}
+
+
+
+function isCentreVPText($role) {
+
+ return $role=="KEY ACCOUNT MANAGER CENTRE" || $role=="DELEGUE COMMERCIAL CENTRE";
+
+}
+
+
+
+function isEstVPText($role) {
+
+ return $role=="KEY ACCOUNT MANAGER EST" || $role=="DELEGUE COMMERCIAL EST" || $role=="DELEGUE COMMERCIAL EST2";
+
+}
+
+
+
+function showNewDashBoard($userID) {
+
+
+
+ require_once 'include/utils/GetGroupUsers.php';
+
+ $userGroups_DB = new GetGroupUsers();
+
+ //145 id group
+
+ $userGroups_DB->getAllUsersInGroup(145);
+
+ $GetGroupUsers_DB = $userGroups_DB->group_users;
+
+ $is = in_array($userID, $GetGroupUsers_DB);
+
+ if($is == true){
+
+ return true;
+
+ }
+
+
+
+
+
+ return false;
+
+}
+
+function hideStock($roleid)
+{
+ return ($roleid == 'H36' || $roleid == 'H44' || $roleid == 'H34' || $roleid == 'H42' || $roleid == 'H38' || $roleid == 'H37');
+}
+
+//note de frais admin
+
+function isAdminNdf($userId){
+
+ global $adb;
+
+
+
+ $query = "SELECT id_validateur_2 FROM note_de_frais_parametres";
+
+ $sql_get_result = $adb->query($query);
+
+ $res= array();
+
+
+
+ while ($recordinfo = $adb->fetch_array($sql_get_result)) {
+
+ $res[] = $recordinfo;
+
+ }
+
+
+
+ if( $userId == 1 || $userId == $res[0]['id_validateur_2']){
+
+ return true;
+
+ }
+
+
+
+ return false;
+
+}
+
+
+
+function generatePassword($user_name, $crypt_type) {
+
+
+
+ $password = makeRandomPassword();
+
+
+
+ $salt = substr($user_name, 0, 2);
+
+ $salt = '$1$' . str_pad($salt, 9, '0');
+
+ $enc_password = crypt($password, $salt);
+
+
+
+ $user_hash = strtolower(md5($password));
+
+
+
+ return [$enc_password, $user_hash, $password];
+
+}
+
+
+function isVPSuperviseur($role){
+ return $role=="H36" || $role=="H44" ||
+ $role=="H34" || $role=="H42" ||
+ $role=="H38" ;
+}
+
+function isResponsableCommercial($role){
+ return $role=="H10" ;
+}
+
+
+?>
+
+
+
+
+
diff --git a/customerportal/layouts/default/resources/components/main.js b/customerportal/layouts/default/resources/components/main.js
index e766f23e..5ed6503b 100644
--- a/customerportal/layouts/default/resources/components/main.js
+++ b/customerportal/layouts/default/resources/components/main.js
@@ -1,298 +1,596 @@
-/*+***********************************************************************************
- * The contents of this file are subject to the vtiger CRM Public License Version 1.2
- * ("License.txt"); You may not use this file except in compliance with the License
- * The Original Code is: Vtiger CRM Open Source
- * The Initial Developer of the Original Code is Vtiger.
- * Portions created by Vtiger are Copyright (C) Vtiger.
- * All Rights Reserved.
- *************************************************************************************/
-
-function MainController($scope, $api, $webapp, $modal, $translate, $translatePartialLoader) {
-
-
- $translatePartialLoader.addPart('login');
- $translatePartialLoader.addPart('home');
- $scope.loginUser = null;
- $scope.modules = [];
- $scope.modulesCount = 0;
- $scope.language = "fr_fr";
- $api.get('Portal/Ping').success(function (user) {
- if (user) {
- $scope.loginUser = true;
- $translate.use(user.language);
- $scope.language = user.language;
- if (localStorage.getItem('modules') !== null && localStorage.getItem('modules') !== 'null') {
- $scope.modules = JSON.parse(localStorage.getItem('modules'));
- $scope.modulesCount = Object.keys($scope.modules).length;
- if (localStorage.getItem('orgName') == undefined) {
- $scope.companyDetails();
- }
- $scope.$root.$emit('LoginUser.Ready');
- } else {
- $scope.fecthModules($scope.language);
- $scope.$root.$emit('LoginUser.Ready');
- }
- }
- });
-
- $scope.fecthModules = function (language) {
-
- $api.get('/FetchModules', {language: language}).success(function (result) {
-
- delete(result.language);
- $scope.modules = result.moduleInfo;
- $scope.modulesCount = Object.keys($scope.modules).length;
- localStorage.setItem('modules', JSON.stringify($scope.modules));
- if (result.endDate !== undefined)
- localStorage.setItem('supportNotification', result.endDate)
- });
- }
-
- $scope.changePassword = function () {
- var modalInstance = $modal.open({
- templateUrl: 'changePassword.template',
- controller: Main_Setting_Component,
- backdrop: 'static',
- keyboard: 'false',
- resolve: {
- record: function () {
- return {};
- },
- api: function () {
- return $api;
- },
- webapp: function () {
- return $webapp;
- },
- module: function () {
- return $scope.module;
- },
- translatePartialLoader: function () {
- return $translatePartialLoader;
- }
- }
- });
- }
-
- $scope.forgotPassword = function () {
- var modalInstance = $modal.open({
- templateUrl: 'forgotPassword.template',
- controller: ForgotPassword_Component,
- backdrop: 'static',
- keyboard: 'false',
- resolve: {
- api: function () {
- return $api;
- },
- webapp: function () {
- return $webapp;
- },
- translatePartialLoader: function () {
- return $translatePartialLoader;
- }
- }
- });
- };
-
- $scope.setLanguage = function (lang) {
- $translate.use(lang);
- };
- $scope.logout = function () {
- localStorage.clear();
- window.location.href = "index.php?module=Portal&view=Logout";
- }
- $scope.isActive = function (module) {
- var url = purl();
- var routeModule = url.param('module');
- if (routeModule !== undefined) {
- if (module === routeModule) {
- return true;
- }
- else {
- return false;
- }
- }
- if (module == 'Home' && routeModule === undefined) {
- return true;
- }
- }
- $scope.companyDetails = function () {
- $api.get('/FetchCompanyDetails').success(function (data) {
- if (data.message === undefined && data.code === undefined)
- $scope.companyInfo = angular.copy(data);
- else if (data.message === 'Contacts module is disabled') {
- alert(data.message);
- localStorage.clear();
- window.location.href = 'index.php?module=Portal&view=Logout';
- }
- })
- }
- $scope.disableSearch = true;
- $scope.Query = {};
- $scope.searchEvent = function (Query) {
- $scope.$broadcast('searchFor', $scope.Query.search);
- }
-
- $scope.makeAutoComplete = function () {
- $scope.$broadcast("autofill:update");
- }
-
- $scope.login = function (validity) {
- q = {};
- q.username = $scope.username;
- q.password = $scope.password;
- q.language = $scope.language;
- if (validity) {
- $scope.noUserName = false;
- $scope.noPassword = false;
- $api.post('Portal/Login', {q: q}).success(function (response) {
- if (response.success) {
- window.location.href = 'index.php';
- }
- else {
- $scope.loginFailed = true;
- $scope.loginMessage = response.error.message;
- }
- });
- }
- else if (!validity) {
- if (q.username === undefined && q.password === undefined) {
- $scope.noUserName = true;
- $scope.loginFailed = false;
- return false;
- }
- if (q.password !== undefined && q.username === undefined) {
- $scope.noUserName = true;
- $scope.noPassword = false;
- $scope.loginFailed = false;
- return false;
- }
- if (q.username !== undefined && q.password === undefined) {
- $scope.noPassword = true;
- $scope.noUserName = false;
- $scope.loginFailed = false;
- return false;
- }
- }
- }
-
- $api.get('Portal/FetchCompanyTitle').then(function (err, data) {
- if (err) {
- //Error fetching company title.
- $scope.companyTitle = '';
- }
- if (data) {
- $scope.companyTitle = data.result;
- }
- })
-}
-
-function Main_Setting_Component($scope, $modalInstance, record, api, $webapp, module, translatePartialLoader) {
- if (translatePartialLoader !== undefined) {
- translatePartialLoader.addPart('home');
- }
- $scope.editRecord = angular.copy(record);
- $scope.data = {'oldPassword': "", 'newPassword': "", 'confirmPassword': ""};
- $scope.save = function () {
- api.post('Portal/ChangePassword', {record: $scope.data}).success(function (result) {
- $modalInstance.dismiss();
- if (result.result.message === undefined) {
- alert(result.result);
- $webapp.busy(false);
- localStorage.clear();
- window.location.href = 'index.php?module=Portal&view=Logout';
- }
- else if (result.result.message !== undefined) {
- alert(result.result.message)
- $webapp.busy(false);
- }
- });
- }
-
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
-}
-
-function ForgotPassword_Component($scope, $modalInstance, api, $webapp, translatePartialLoader) {
- if (translatePartialLoader !== undefined) {
- translatePartialLoader.addPart('home');
- }
- $scope.data = {'email': ""};
- $scope.updatePassword = function () {
- $webapp.busy(true);
- api.post('Portal/ForgotPassword', {email: $scope.data.email}).success(function (data) {
- $modalInstance.dismiss();
- if (data.result.message === undefined) {
- alert(data.result);
- }
- else if (data.result.message !== undefined) {
- alert(data.result.message);
- }
- $webapp.busy(false);
- });
- };
-
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
-}
-
-function globalSearchController($scope, $http, $timeout, $webapp, $translate) {
-
- jQuery(".search-icon").on('click', function (e) {
- jQuery(".search-box").focus();
- })
-
- $scope.search = '';
-
- $scope.getModuleLabelClass = function (module) {
- return 'label label-info';
- }
-
- $scope.searchItemSelected = function (item, $timeout) {
- if (item.model.count > 0) {
- var module = item.model.module.module;
- var url = "index.php?module=" + module + "&view=Detail&id=" + item.model.id;
- window.location.href = url;
- }
- else {
- $scope.search = '';
- return false;
- }
- }
-
- $scope.searchRecords = function (searchKey, $timeout) {
- var params = {
- "api": "SearchRecords",
- "searchKey": searchKey,
- "module": "Portal"
- };
- var result = [];
- return $http.get("index.php", {params: params}).then(function (response) {
- $webapp.busy();
- var data = response.data.result;
- angular.forEach(data, function (moduleInfo, i) {
- if (angular.isObject(moduleInfo) && moduleInfo.length !== 0) {
- if (i !== 'language') {
- var labelField = 'label';
- angular.forEach(moduleInfo, function (recordInfo) {
- if (recordInfo.hasOwnProperty('id')) {
- var res = {value: recordInfo[labelField], module: {"module": i, "uiLabel": moduleInfo.uiLabel}, id: recordInfo.id, count: 1};
- result.push(res);
- }
- });
- }
- }
- });
- if (result.length < 1) {
- //No results found
- $scope.noMatchFound = true;
- var noRecords = {value: $translate.instant('No matches found.'), module: {}, count: 0};
- result.push(noRecords);
- }
- $webapp.busy(false);
- return result;
- });
- }
-}
+/*+***********************************************************************************
+
+ * The contents of this file are subject to the vtiger CRM Public License Version 1.2
+
+ * ("License.txt"); You may not use this file except in compliance with the License
+
+ * The Original Code is: Vtiger CRM Open Source
+
+ * The Initial Developer of the Original Code is Vtiger.
+
+ * Portions created by Vtiger are Copyright (C) Vtiger.
+
+ * All Rights Reserved.
+
+ *************************************************************************************/
+
+
+
+function MainController($scope, $api, $webapp, $modal, $translate, $translatePartialLoader) {
+
+
+
+
+
+ $translatePartialLoader.addPart('login');
+
+ $translatePartialLoader.addPart('home');
+
+ $scope.loginUser = null;
+
+ $scope.modules = [];
+
+ $scope.modulesCount = 0;
+
+ $scope.language = "fr_fr";
+
+ $api.get('Portal/Ping').success(function (user) {
+
+ if (user) {
+
+ $scope.loginUser = true;
+
+ $translate.use(user.language);
+
+ $scope.language = user.language;
+
+ if (localStorage.getItem('modules') !== null && localStorage.getItem('modules') !== 'null') {
+
+ $scope.modules = JSON.parse(localStorage.getItem('modules'));
+
+ $scope.modulesCount = Object.keys($scope.modules).length;
+
+ if (localStorage.getItem('orgName') == undefined) {
+
+ $scope.companyDetails();
+
+ }
+
+ $scope.$root.$emit('LoginUser.Ready');
+
+ } else {
+
+ $scope.fecthModules($scope.language);
+
+ $scope.$root.$emit('LoginUser.Ready');
+
+ }
+
+ }
+
+ });
+
+
+
+ $scope.fecthModules = function (language) {
+
+
+
+ $api.get('/FetchModules', {language: language}).success(function (result) {
+
+
+
+ delete(result.language);
+
+ $scope.modules = result.moduleInfo;
+
+ $scope.modulesCount = Object.keys($scope.modules).length;
+
+ localStorage.setItem('modules', JSON.stringify($scope.modules));
+
+ if (result.endDate !== undefined)
+
+ localStorage.setItem('supportNotification', result.endDate)
+
+ });
+
+ }
+
+
+
+ $scope.changePassword = function () {
+
+ var modalInstance = $modal.open({
+
+ templateUrl: 'changePassword.template',
+
+ controller: Main_Setting_Component,
+
+ backdrop: 'static',
+
+ keyboard: 'false',
+
+ resolve: {
+
+ record: function () {
+
+ return {};
+
+ },
+
+ api: function () {
+
+ return $api;
+
+ },
+
+ webapp: function () {
+
+ return $webapp;
+
+ },
+
+ module: function () {
+
+ return $scope.module;
+
+ },
+
+ translatePartialLoader: function () {
+
+ return $translatePartialLoader;
+
+ }
+
+ }
+
+ });
+
+ }
+
+
+
+ $scope.forgotPassword = function () {
+
+ var modalInstance = $modal.open({
+
+ templateUrl: 'forgotPassword.template',
+
+ controller: ForgotPassword_Component,
+
+ backdrop: 'static',
+
+ keyboard: 'false',
+
+ resolve: {
+
+ api: function () {
+
+ return $api;
+
+ },
+
+ webapp: function () {
+
+ return $webapp;
+
+ },
+
+ translatePartialLoader: function () {
+
+ return $translatePartialLoader;
+
+ }
+
+ }
+
+ });
+
+ };
+
+
+
+ $scope.setLanguage = function (lang) {
+
+ $translate.use(lang);
+
+ };
+
+ $scope.logout = function () {
+
+ localStorage.clear();
+
+ window.location.href = "index.php?module=Portal&view=Logout";
+
+ }
+
+ $scope.isActive = function (module) {
+
+ var url = purl();
+
+ var routeModule = url.param('module');
+
+ if (routeModule !== undefined) {
+
+ if (module === routeModule) {
+
+ return true;
+
+ }
+
+ else {
+
+ return false;
+
+ }
+
+ }
+
+ if (module == 'Home' && routeModule === undefined) {
+
+ return true;
+
+ }
+
+ }
+
+ $scope.companyDetails = function () {
+
+ $api.get('/FetchCompanyDetails').success(function (data) {
+
+ if (data.message === undefined && data.code === undefined)
+
+ $scope.companyInfo = angular.copy(data);
+
+ else if (data.message === 'Contacts module is disabled') {
+
+ alert(data.message);
+
+ localStorage.clear();
+
+ window.location.href = 'index.php?module=Portal&view=Logout';
+
+ }
+
+ })
+
+ }
+
+ $scope.disableSearch = true;
+
+ $scope.Query = {};
+
+ $scope.searchEvent = function (Query) {
+
+ $scope.$broadcast('searchFor', $scope.Query.search);
+
+ }
+
+
+
+ $scope.makeAutoComplete = function () {
+
+ $scope.$broadcast("autofill:update");
+
+ }
+
+
+
+ $scope.login = function (validity) {
+
+ q = {};
+
+ q.username = $scope.username;
+
+ q.password = $scope.password;
+
+ q.language = $scope.language;
+
+ if (validity) {
+
+ $scope.noUserName = false;
+
+ $scope.noPassword = false;
+
+ $api.post('Portal/Login', {q: q}).success(function (response) {
+
+ if (response.success) {
+
+ window.location.href = 'index.php';
+
+ }
+
+ else {
+
+ $scope.loginFailed = true;
+
+ $scope.loginMessage = response.error.message;
+
+ }
+
+ });
+
+ }
+
+ else if (!validity) {
+
+ if (q.username === undefined && q.password === undefined) {
+
+ $scope.noUserName = true;
+
+ $scope.loginFailed = false;
+
+ return false;
+
+ }
+
+ if (q.password !== undefined && q.username === undefined) {
+
+ $scope.noUserName = true;
+
+ $scope.noPassword = false;
+
+ $scope.loginFailed = false;
+
+ return false;
+
+ }
+
+ if (q.username !== undefined && q.password === undefined) {
+
+ $scope.noPassword = true;
+
+ $scope.noUserName = false;
+
+ $scope.loginFailed = false;
+
+ return false;
+
+ }
+
+ }
+
+ }
+
+
+
+ $api.get('Portal/FetchCompanyTitle').then(function (err, data) {
+
+ if (err) {
+
+ //Error fetching company title.
+
+ $scope.companyTitle = '';
+
+ }
+
+ if (data) {
+
+ $scope.companyTitle = data.result;
+
+ }
+
+ })
+
+}
+
+
+
+function Main_Setting_Component($scope, $modalInstance, record, api, $webapp, module, translatePartialLoader) {
+
+ if (translatePartialLoader !== undefined) {
+
+ translatePartialLoader.addPart('home');
+
+ }
+
+ $scope.editRecord = angular.copy(record);
+
+ $scope.data = {'oldPassword': "", 'newPassword': "", 'confirmPassword': ""};
+
+ $scope.save = function () {
+
+ api.post('Portal/ChangePassword', {record: $scope.data}).success(function (result) {
+
+ $modalInstance.dismiss();
+
+ if (result.result.message === undefined) {
+
+ alert(result.result);
+
+ $webapp.busy(false);
+
+ localStorage.clear();
+
+ window.location.href = 'index.php?module=Portal&view=Logout';
+
+ }
+
+ else if (result.result.message !== undefined) {
+
+ alert(result.result.message)
+
+ $webapp.busy(false);
+
+ }
+
+ });
+
+ }
+
+
+
+ $scope.cancel = function () {
+
+ $modalInstance.dismiss('cancel');
+
+ }
+
+}
+
+
+
+function ForgotPassword_Component($scope, $modalInstance, api, $webapp, translatePartialLoader) {
+
+ if (translatePartialLoader !== undefined) {
+
+ translatePartialLoader.addPart('home');
+
+ }
+
+ $scope.data = {'email': ""};
+
+ $scope.updatePassword = function () {
+
+ $webapp.busy(true);
+
+ api.post('Portal/ForgotPassword', {email: $scope.data.email}).success(function (data) {
+
+ $modalInstance.dismiss();
+
+ if (data.result.message === undefined) {
+
+ alert(data.result);
+
+ }
+
+ else if (data.result.message !== undefined) {
+
+ alert(data.result.message);
+
+ }
+
+ $webapp.busy(false);
+
+ });
+
+ };
+
+
+
+ $scope.cancel = function () {
+
+ $modalInstance.dismiss('cancel');
+
+ }
+
+}
+
+
+
+function globalSearchController($scope, $http, $timeout, $webapp, $translate) {
+
+
+
+ jQuery(".search-icon").on('click', function (e) {
+
+ jQuery(".search-box").focus();
+
+ })
+
+
+
+ $scope.search = '';
+
+
+
+ $scope.getModuleLabelClass = function (module) {
+
+ return 'label label-info';
+
+ }
+
+
+
+ $scope.searchItemSelected = function (item, $timeout) {
+
+ if (item.model.count > 0) {
+
+ var module = item.model.module.module;
+
+ var url = "index.php?module=" + module + "&view=Detail&id=" + item.model.id;
+
+ window.location.href = url;
+
+ }
+
+ else {
+
+ $scope.search = '';
+
+ return false;
+
+ }
+
+ }
+
+
+
+ $scope.searchRecords = function (searchKey, $timeout) {
+
+ var params = {
+
+ "api": "SearchRecords",
+
+ "searchKey": searchKey,
+
+ "module": "Portal"
+
+ };
+
+ var result = [];
+
+ return $http.get("index.php", {params: params}).then(function (response) {
+
+ $webapp.busy();
+
+ var data = response.data.result;
+
+ angular.forEach(data, function (moduleInfo, i) {
+
+ if (angular.isObject(moduleInfo) && moduleInfo.length !== 0) {
+
+ if (i !== 'language') {
+
+ var labelField = 'label';
+
+ angular.forEach(moduleInfo, function (recordInfo) {
+
+ if (recordInfo.hasOwnProperty('id')) {
+
+ var res = {value: recordInfo[labelField], module: {"module": i, "uiLabel": moduleInfo.uiLabel}, id: recordInfo.id, count: 1};
+
+ result.push(res);
+
+ }
+
+ });
+
+ }
+
+ }
+
+ });
+
+ if (result.length < 1) {
+
+ //No results found
+
+ $scope.noMatchFound = true;
+
+ var noRecords = {value: $translate.instant('No matches found.'), module: {}, count: 0};
+
+ result.push(noRecords);
+
+ }
+
+ $webapp.busy(false);
+
+ return result;
+
+ });
+
+ }
+
+}
+
diff --git a/customerportal/libraries/Smarty/demo/templates/footer.tpl b/customerportal/libraries/Smarty/demo/templates/footer.tpl
index 1ff8a70b..364f036a 100644
--- a/customerportal/libraries/Smarty/demo/templates/footer.tpl
+++ b/customerportal/libraries/Smarty/demo/templates/footer.tpl
@@ -1,2 +1,4 @@
-
-