function display()
 {
     $ss = new Sugar_Smarty();
     $table = array('Leads' => 'Leads', 'Opportunities' => 'Opportunities', 'FITs' => 'Customer', 'Contacts' => 'Contacts', 'Accounts' => 'Company', 'Cases' => 'Cases', 'Notes' => 'Notes', 'Calls' => 'Calls', 'Emails' => 'Emails', 'Meetings' => 'Meetings', 'Tasks' => 'Tasks');
     $timedate = new TimeDate();
     global $db, $mod_strings, $app_list_strings, $current_user;
     $ss = new Sugar_Smarty();
     $ss->assign('MOD', $mod_strings);
     $focus = new C_Reports();
     $role = $focus->getUserRole('Reports', $current_user->id);
     $list_user = $focus->getUserForReportAsRole();
     $list_group = $focus->getAllSecuritySuite();
     $ss->assign('lst_group', get_select_options_with_id($app_list_strings['report_securitysuite_dom'], ''));
     $ss->assign('lst_user', get_select_options_with_id($app_list_strings['report_user_dom'], ''));
     if (isset($_REQUEST['submit'])) {
         $start_date = $_REQUEST['start_date'];
         $end_date = $_REQUEST['end_date'];
         $user_id = $_REQUEST['lst_user'];
         $list_user = $_REQUEST['user_id'];
         $time_range = $_REQUEST['time_range'];
         $start_end_yes = $_REQUEST['start_end_yes'];
         $report_option = $_REQUEST['report_option'];
         $type = $time_range ? $time_range : $start_end_yes;
         $ss->assign('TYPE', $type);
         $ss->assign('report_option', $report_option);
         $lst_user = get_select_options($app_list_strings['report_user_dom'], $user_id);
         $ss->assign('lst_user', $lst_user);
         if ($list_user) {
             $user_id = json_decode(base64_decode($list_user));
             if (count($user_id) > 0) {
                 $user_id = $user_id;
             }
         }
         if ($user_id) {
             $user_id = (array) $user_id;
         } else {
             unset($app_list_strings['report_user_dom']['0']);
             $user_id = array_keys($app_list_strings['report_user_dom']);
         }
         if ($group) {
             $group = (array) $group;
         } else {
             unset($app_list_strings['report_securitysuite_dom']['0']);
             $group = array_keys($app_list_strings['report_securitysuite_dom']);
         }
         $dateOp = new AdvancedDatetimeOperations($focus);
         $user_format = $timedate->get_date_format($current_user);
         $date_format = $_REQUEST['date_format'] != '' ? $_REQUEST['date_format'] : $user_format;
         if ($start_end_yes) {
             $time_range = '';
             $start_date = $timedate->to_display($_REQUEST['start_date'], $date_format, 'Y-m-d');
             $end_date = $timedate->to_display($_REQUEST['end_date'], $date_format, 'Y-m-d');
         } else {
             $start_date = date('Y-m-d');
             $end_date = date('Y-m-d');
             $dateOp->calc_date2($start_date, $end_date, $time_range);
         }
         $date_start = $timedate->to_display($start_date, 'Y-m-d', $user_format);
         $date_end = $timedate->to_display($end_date, 'Y-m-d', $user_format);
         $html = '';
         $html = '<br /><div style="color:red"><b>Note : (Created/Assigned/Modified)</b></div>';
         $html .= '<table class="h3Row" cellpadding="0" cellspacing="0" width="100%" border="1" style="border-collapse: collapse;"> ';
         $html .= '<thead>';
         $html .= '<td class="tb_border" style="background:#EBEBED"><b>User</b></td>';
         foreach ($table as $table_name) {
             $html .= '<td style="background:#EBEBED;text-align:center" class="tb_border" width="' . 100 / count($table) . '%"><b>' . $table_name . '</b></td>';
         }
         $html .= '</tr>';
         $html .= '</thead>';
         if (count($user_id) > 0 && $user_id[0] != '0') {
             foreach ($user_id as $value) {
                 $html .= '<tr height="20">';
                 $html .= '<td class="tb_border"> ' . translate('report_user_dom', '', $value) . ' </td>';
                 foreach ($table as $table_value => $table_name) {
                     $recordCreate = $focus->countRecordCreate(strtolower($table_value), $value, $start_date, $end_date);
                     $recordModify = $focus->countRecordAsignedTo(strtolower($table_value), $value, $start_date, $end_date);
                     $recordModified = $focus->countRecordModify(strtolower($table_value), $value, $start_date, $end_date);
                     if ($recordCreate > 0) {
                         $create_url = '<a target="blank" href="index.php?module=' . $table_value . '&action=index&query=true&created_by_basic=' . $value . '&date_entered_basic_range_choice=between&start_range_date_entered_basic=' . $date_start . '&end_range_date_entered_basic=' . $date_end . '&searchFormTab=basic_search">' . $recordCreate . '</a>';
                     } else {
                         $create_url = $recordCreate;
                     }
                     if ($recordModify > 0) {
                         $modify_url = '<a target="blank" href="index.php?module=' . $table_value . '&action=index&query=true&assigned_user_id=' . $value . '&date_modified_basic_range_choice=between&start_range_date_modified_basic=' . $date_start . '&end_range_date_modified_basic=' . $date_end . '&searchFormTab=basic_search">' . $recordModify . '</a>';
                     } else {
                         $modify_url = $recordModify;
                     }
                     if ($recordModified > 0) {
                         $modified_url = '<a target="blank" href="index.php?module=' . $table_value . '&action=index&query=true&modified_user_id_basic=' . $value . '&date_modified_basic_range_choice=between&start_range_date_modified_basic=' . $date_start . '&end_range_date_modified_basic=' . $date_end . '&searchFormTab=basic_search">' . $recordModified . '</a>';
                     } else {
                         $modified_url = $recordModified;
                     }
                     $html .= '<td style="text-align:center" class="tb_border">' . $create_url . ' / ' . $modify_url . ' / ' . $modified_url . ' </td>';
                 }
                 $html .= '</tr>';
             }
         }
         //$countACC = $focus->get_audit_table_name();
         $html .= '</table>';
         // $start_date = $timedate->to_display($_REQUEST['start_date'],$date_format,$user_format);
         //  $end_date = $timedate->to_display($_REQUEST['end_date'],$date_format,$user_format);
         $ss->assign('start_date', $_REQUEST['start_date']);
         $ss->assign('end_date', $_REQUEST['end_date']);
         $ss->assign('date_format', $user_format);
     }
     $html .= '<script type="text/javascript"> 
         jQuery(document).ready(function(){
            jQuery("table[class=\'h3Row\']").find("tbody").find("tr:even").addClass("evenListRowS1");
            jQuery("table[class=\'h3Row\']").find("tbody").find("tr:odd").addClass("oddListRowS1");
         });
         </script>';
     $ss->assign('CONTENT', $html);
     $ss->display("modules/C_Reports/tpls/Synthesis_Report.tpl");
 }
 function display()
 {
     $focus = new C_Reports();
     global $db;
     global $app_strings;
     global $app_list_strings;
     global $mod_strings;
     global $currentModule;
     $ketqua = '';
     $export = '';
     $file_name = '';
     $ss = new Sugar_Smarty();
     $ss->assign("APP", $app_strings);
     $ss->assign("MOD", $mod_strings);
     $ss->assign('CURRENT_MODULE', $currentModule);
     $ss->assign('KY', get_select_options($app_list_strings['tinhdiem_ky_dom'], ''));
     $ss->assign('THANG', get_select_options($app_list_strings['tinhdiem_thang_dom'], ''));
     $ss->assign('DEPARTMENT', get_select_options($app_list_strings['report_deparment_dom'], 'any'));
     if ((isset($_REQUEST['tinhdiem']) || isset($_REQUEST['tinhdiemsales']) || isset($_REQUEST['tinhdiemtelesales']) || isset($_REQUEST['xephang']) || isset($_REQUEST['xephangsales']) || isset($_REQUEST['xephangtelesales']) || isset($_REQUEST['export'])) && $_REQUEST['nam'] != '') {
         //////////////////////////////////////
         //Khai bao bien
         $ds_ketqua = array();
         $rate = '';
         $type_calculate = '';
         $type_value = '';
         $start_date = '';
         $end_date = '';
         $report_type = '';
         $check_sale_man = $_REQUEST['check_sale_man'];
         $sale_man = $_REQUEST['sale_man'];
         $sale_man_id = $_REQUEST['sale_man_id'];
         $department = $_REQUEST['department'];
         if (isset($_REQUEST['report_type'])) {
             $report_type = $_REQUEST['report_type'];
         }
         if (isset($_REQUEST['export'])) {
             $export = 1;
         }
         $ky = $_REQUEST['ky'];
         $thang = $_REQUEST['thang'];
         $nam = $_REQUEST['nam'];
         if ($check_sale_man == '1') {
             $ss->assign('CHECK_SALE_MAN', 'checked="checked"');
         } elseif ($check_sale_man == '0') {
             $ss->assign('CHECK_SALE_MAN', '');
         }
         $ss->assign('SALE_MAN', $sale_man);
         $ss->assign('SALE_MAN_ID', $sale_man_id);
         $ss->assign('KY', get_select_options($app_list_strings['tinhdiem_ky_dom'], $ky));
         $ss->assign('THANG', get_select_options($app_list_strings['tinhdiem_thang_dom'], $thang));
         $ss->assign('DEPARTMENT', get_select_options($app_list_strings['report_deparment_dom'], $department));
         $ss->assign('NAM', $nam);
         ///////////////////////////////////////
         // Tinh ngay bat dau va ngay ket thuc de cham diem
         if (isset($_REQUEST['xephangsales']) || isset($_REQUEST['xephangtelesales']) || isset($_REQUEST['xephang']) || $report_type == 5 || $report_type == 6 || $report_type == 7 || $report_type == 8) {
             foreach ($thang as $thang_unit) {
                 $start_date[] = $nam . '-' . $thang_unit . '-01';
                 $end_date[] = date('Y-m-d', strtotime('-1 second', strtotime('+1 month', strtotime($thang_unit . '/01/' . $nam . ' 00:00:00'))));
             }
         } else {
             if ($ky == '1') {
                 foreach ($thang as $thang_unit) {
                     $start_date[] = $nam . '-' . $thang_unit . '-01';
                     $end_date[] = $nam . '-' . $thang_unit . '-16';
                 }
             } else {
                 foreach ($thang as $thang_unit) {
                     $start_date[] = $nam . '-' . $thang_unit . '-16';
                     $end_date[] = date('Y-m-d', strtotime('-1 second', strtotime('+1 month', strtotime($thang_unit . '/01/' . $nam . ' 00:00:00'))));
                 }
             }
         }
         ////////////////////////////////////////
         // Lay ket qua
         if (isset($_REQUEST['tinhdiemtelesales']) || $report_type == 1 && $export == 1) {
             if ($report_type != 1) {
                 $report_type = 1;
             }
             $ketqua = $focus->getDanhSachDiemCuaNhanVienTeleSale($app_strings, $mod_strings, $ds_ketqua, $start_date, $end_date, $sale_man_id, $department, null, $export, $report_type);
             $type_value = 1;
             $type_calculate = $mod_strings['LBL_TINH_DIEM_TELESALES'];
         } elseif (isset($_REQUEST['tinhdiemsales']) || $report_type == 2 && $export == 1) {
             if ($report_type != 2) {
                 $report_type = 2;
             }
             $ketqua = $focus->getDanhSachDiemCuaNhanVienSale($app_strings, $mod_strings, $ds_ketqua, $start_date, $end_date, $sale_man_id, $department, null, $export, $report_type);
             $type_value = 2;
             $type_calculate = $mod_strings['LBL_TINH_DIEM_SALES'];
         } elseif (isset($_REQUEST['tinhdiem']) || ($report_type == 3 || $report_type == 4) && $export == 1) {
             $user = new User();
             $user->retrieve($sale_man_id);
             if ($user->type_sale == 'telesales' || $report_type == 3) {
                 if ($report_type != 3) {
                     $report_type = 3;
                 }
                 $ketqua = $focus->getDanhSachDiemCuaNhanVienTeleSale($app_strings, $mod_strings, $ds_ketqua, $start_date, $end_date, $sale_man_id, $department, null, $export, $report_type);
                 $type_value = 1;
                 $type_calculate = $mod_strings['LBL_TINH_DIEM_TELESALES'] . ' ' . $user->last_name;
             } elseif ($user->type_sale == 'sales' || $report_type == 4) {
                 if ($report_type != 4) {
                     $report_type = 4;
                 }
                 $ketqua = $focus->getDanhSachDiemCuaNhanVienSale($app_strings, $mod_strings, $ds_ketqua, $start_date, $end_date, $sale_man_id, $department, null, $export, $report_type);
                 $type_value = 2;
                 $type_calculate = $mod_strings['LBL_TINH_DIEM_SALES'] . ' ' . $user->last_name;
             }
         } elseif (isset($_REQUEST['xephangtelesales']) || $report_type == 5 && $export == 1) {
             if ($report_type != 5) {
                 $report_type = 5;
             }
             $ketqua = $focus->getDanhSachDiemCuaNhanVienTeleSale($app_strings, $mod_strings, $ds_ketqua, $start_date, $end_date, $sale_man_id, $department, 1, $export, $report_type);
             $type_value = 1;
             $rate = 1;
             $type_calculate = $mod_strings['LBL_XEP_HANG_TELESALES'];
         } elseif (isset($_REQUEST['xephangsales']) || $report_type == 6 && $export == 1) {
             if ($report_type != 6) {
                 $report_type = 6;
             }
             $ketqua = $focus->getDanhSachDiemCuaNhanVienSale($app_strings, $mod_strings, $ds_ketqua, $start_date, $end_date, $sale_man_id, $department, 1, $export, $report_type);
             $type_value = 2;
             $rate = 1;
             $type_calculate = $mod_strings['LBL_XEP_HANG_SALES'];
         } elseif (isset($_REQUEST['xephang']) || ($report_type == 7 || $report_type == 8) && $export == 1) {
             $user = new User();
             $user->retrieve($sale_man_id);
             if ($user->type_sale == 'telesales' || $report_type == 7) {
                 if ($report_type != 7) {
                     $report_type = 7;
                 }
                 $ketqua = $focus->getDanhSachDiemCuaNhanVienTeleSale($app_strings, $mod_strings, $ds_ketqua, $start_date, $end_date, $sale_man_id, $department, 1, $export, $report_type);
                 $type_value = 1;
                 $type_calculate = $mod_strings['LBL_XEP_HANG_TELESALES'] . ' ' . $user->last_name;
             } elseif ($user->type_sale == 'sales' || $report_type == 8) {
                 if ($report_type != 8) {
                     $report_type = 8;
                 }
                 $ketqua = $focus->getDanhSachDiemCuaNhanVienSale($app_strings, $mod_strings, $ds_ketqua, $start_date, $end_date, $sale_man_id, $department, 1, $export, $report_type);
                 $type_value = 2;
                 $type_calculate = $mod_strings['LBL_XEP_HANG_SALES'] . ' ' . $user->last_name;
             }
             $rate = 1;
         }
         /////////////////////////////////////////////
         // Kiem tra ky de chinh lai end_date, chinh lai thanh ngay 15.
         // Tuy chinh giao dien ben ngoai cho phu hop voi loai tinh diem.
         if ($ky == '1' && !isset($_REQUEST['xephangtelesales']) && !isset($_REQUEST['xephangsales']) && !isset($_REQUEST['xephang']) && $report_type != 5 && $report_type != 6 && $report_type != 7 && $report_type != 8) {
             $end_date_temp = explode('-', $end_date);
             $end_date_temp[2] -= 1;
             $end_date = $end_date_temp[0] . '-' . $end_date_temp[1] . '-' . $end_date_temp[2];
         }
         $file_name = $type_calculate;
         //   $type_calculate .= $mod_strings['LBL_START_DATE'].'<font color=red>'.date('d-m-Y',strtotime($start_date)).'</font>'.$mod_strings['LBL_END_DATE'].'<font color=red>'.date('d-m-Y',strtotime($end_date)).'</font>' ;
         //  $ss->assign('TYPE_CALCULATE',$type_calculate);
         $ss->assign('TYPE_VALUE', $type_value);
         $ss->assign('RATE', $rate);
         if ($ketqua == '') {
             $ketqua = '<tr><td colspan="16">' . $mod_strings['LBL_NODATA'] . '</td></tr>';
         }
         ////////////////////////////////////////////////
     } else {
         ///////////////////////////////////////////////
         // Neu khong co du lieu
         $ketqua = '<tr><td colspan="16">' . $mod_strings['LBL_NODATA'] . '</td></tr>';
     }
     /**
      * Kiem tra kieu du lieu :
      * 1. View Table
      * 2. File Excel
      */
     if ($export != 1) {
         $ss->assign('KETQUA', $ketqua);
         $ss->display("modules/C_Reports/tpls/tinhdiemnhanvien.tpl");
     } else {
         /**
          * Export To Excel:
          */
         if ($report_type == 1 || $report_type == 3) {
             $temp = file_get_contents("modules/C_Reports/tpls/FormExport_Telesales_files/sheet001.htm");
         } elseif ($report_type == 2 || $report_type == 4) {
             $temp = file_get_contents("modules/C_Reports/tpls/FormExport_Sales_files/sheet001.htm");
         } elseif ($report_type == 5 || $report_type == 7) {
             $temp = file_get_contents("modules/C_Reports/tpls/FormExport_Telesales_XepHang_files/sheet001.htm");
         } elseif ($report_type == 6 || $report_type == 8) {
             $temp = file_get_contents("modules/C_Reports/tpls/FormExport_Sales_XepHang_files/sheet001.htm");
         }
         $temp = str_replace('{TITLE}', $mod_strings['LBL_TITLE'], $temp);
         $temp = str_replace('{LBL_STT}', $mod_strings['LBL_STT'], $temp);
         $temp = str_replace('{LBL_SALE_NAME}', $mod_strings['LBL_SALE_NAME'], $temp);
         $temp = str_replace('{LBL_PHONGBAN}', $mod_strings['LBL_PHONGBAN'], $temp);
         $temp = str_replace('{LBL_LIST}', $mod_strings['LBL_LIST'], $temp);
         $temp = str_replace('{LBL_LEADS}', $mod_strings['LBL_LEADS'], $temp);
         $temp = str_replace('{LBL_ACCOUNT}', $mod_strings['LBL_ACCOUNT'], $temp);
         $temp = str_replace('{LBL_SUCCESS}', $mod_strings['LBL_SUCCESS'], $temp);
         $temp = str_replace('{LBL_TOTAL}', $mod_strings['LBL_TOTAL'], $temp);
         $temp = str_replace('{LBL_QUANTITY}', $mod_strings['LBL_QUANTITY'], $temp);
         $temp = str_replace('{LBL_SCORE}', $mod_strings['LBL_SCORE'], $temp);
         $temp = str_replace('{LBL_SCORE2}', $mod_strings['LBL_SCORE2'], $temp);
         $temp = str_replace('{LBL_SCOREx2}', $mod_strings['LBL_SCOREx2'], $temp);
         $temp = str_replace('{LBL_CUSTOMERS}', $mod_strings['LBL_CUSTOMERS'], $temp);
         $temp = str_replace('{LBL_KHACHMOI}', $mod_strings['LBL_KHACHMOI'], $temp);
         $temp = str_replace('{LBL_KHACHCU}', $mod_strings['LBL_KHACHCU'], $temp);
         $temp = str_replace('{LBL_TYLE}', $mod_strings['LBL_TYLE'], $temp);
         $temp = str_replace('{LBL_RAKING}', $mod_strings['LBL_RAKING'], $temp);
         $temp = str_replace('{LBL_KETQUA}', $mod_strings['LBL_KETQUA'], $temp);
         $temp = str_replace('{TYPE_CALCULATE}', $type_calculate, $temp);
         $temp = str_replace('{KETQUA}', $ketqua, $temp);
         ob_clean();
         header("Pragma: cache");
         $temp = chr(255) . chr(254) . mb_convert_encoding($temp, "UTF-16LE", "UTF-8");
         header("Content-type: application/x-msdownload");
         header("Content-disposition: xls; filename=" . $mod_strings['LBL_FILENAME'] . "_" . $file_name . ".xls; size=" . strlen($temp));
         echo $temp;
         exit;
     }
 }
Exemple #3
0
    function display()
    {
        $report = new C_Reports();
        if (!$report->ACLAccess('list')) {
            sugar_die("This are is protected");
        }
        global $app_strings;
        global $app_list_strings;
        global $mod_strings;
        global $theme;
        global $currentModule;
        global $current_language;
        global $gridline;
        global $current_user;
        global $sugar_flavor;
        $theme_path = "themes/" . $theme . "/";
        $image_path = $theme_path . "images/";
        $image_path_default = "themes/default/images/";
        require_once $theme_path . 'layout_utils.php';
        ?>
        <h1><?php 
        echo $mod_strings['LBL_SCORES'];
        ?>
</h1>
        
        <table border="0" cellpadding="0" cellspacing="1" width="100%" class="h3Row"><tr>
            <tr>
                <td class="tabDetailViewDF" nowrap="nowrap" width="20%"><img src="themes/default/images/detailview.gif" width='16' height='16' alt="" border="0" align="absmiddle" />
                    <a href="<?php 
        echo "./index.php?module=" . $currentModule . "&action=tinhdiemnhanvien";
        ?>
"><strong><?php 
        echo $mod_strings['LBL_SALE_SCORE'];
        ?>
</strong></a></td>
                <td style="text-align: left;" class="tabDetailViewDL" width="30%">
                  <span>
                  <?php 
        echo $mod_strings['LBL_SALE_SCORE_DES'];
        ?>
                    </span>  
                </td>
            </tr>
            <tr>
                <td class="tabDetailViewDF" nowrap="nowrap" width="20%">
                    <a href="<?php 
        echo "./index.php?module=" . $currentModule . "&action=reportuseractivitives";
        ?>
"><strong>
                    <?php 
        echo $mod_strings['LBL_REPORT_USER_ACTIVITIVES'];
        ?>
</strong></a>
                </td>
                <td class="tabDetailViewDL" width="30%"><?php 
        echo $mod_strings['LBL_REPORT_USER_ACTIVITIVES_DESCRIPTION'];
        ?>
</td>
            </tr>
            <tr>
                <td class="tabDetailViewDF" nowrap="nowrap" width="20%">
                     <a class="integrated_report" id="integrated_report" 
                     href="<?php 
        echo "./index.php?module=" . $currentModule . "&action=synthesis_report";
        ?>
"><strong> <?php 
        echo $mod_strings['LBL_REPORT_SUMMARY'];
        ?>
</strong></a></td>  
                </td>
                 <td class="tabDetailViewDL" width="30%"><?php 
        echo $mod_strings['LBL_REPORT_SUMMARY_DESCRIPTION'];
        ?>
</td>
            </tr>
        </table>    
            
       
    <?php 
    }