Пример #1
0
/**
 *
 * @package Advanced OpenPortal
 * @copyright SalesAgility Ltd http://www.salesagility.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 * along with this program; if not, see http://www.gnu.org/licenses
 * or write to the Free Software Foundation,Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301  USA
 *
 * @author Salesagility Ltd <*****@*****.**>
 */
function display_updates($focus, $field, $value, $view)
{
    global $mod_strings;
    $hideImage = SugarThemeRegistry::current()->getImageURL('basic_search.gif');
    $showImage = SugarThemeRegistry::current()->getImageURL('advanced_search.gif');
    //Javascript for Asynchronous update
    $html = <<<A
<script>
var hideUpdateImage = '{$hideImage}';
var showUpdateImage = '{$showImage}';
function collapseAllUpdates(){
    \$('.caseUpdateImage').attr("src",showUpdateImage);
    \$('.caseUpdate').slideUp('fast');
}
function expandAllUpdates(){
    \$('.caseUpdateImage').attr("src",hideUpdateImage);
    \$('.caseUpdate').slideDown('fast');
}
function toggleCaseUpdate(updateId){
    var id = 'caseUpdate'+updateId;
    var updateElem = \$('#'+id);
    var imageElem = \$('#'+id+"Image");

    if(updateElem.is(":visible")){
        imageElem.attr("src",showUpdateImage);
    }else{
        imageElem.attr("src",hideUpdateImage);
    }
    updateElem.slideToggle('fast');
}
function caseUpdates(record){
    loadingMessgPanl = new YAHOO.widget.SimpleDialog('loading', {
                    width: '200px',
                    close: true,
                    modal: true,
                    visible: true,
                    fixedcenter: true,
                    constraintoviewport: true,
                    draggable: false
                });
    loadingMessgPanl.setHeader(SUGAR.language.get('app_strings', 'LBL_EMAIL_PERFORMING_TASK'));
    loadingMessgPanl.setBody(SUGAR.language.get('app_strings', 'LBL_EMAIL_ONE_MOMENT'));
    loadingMessgPanl.render(document.body);
    loadingMessgPanl.show();

    var update_data = encodeURIComponent(document.getElementById('update_text').value);
    var checkbox = document.getElementById('internal').checked;
    var internal = "";
    if(checkbox){
        internal=1;
    }

    //Post parameters

    var params =
        "record="+record+"&module=Cases&return_module=Cases&action=Save&return_id="+record+"&return_action=DetailView&relate_to=Cases&relate_id="+record+"&offset=1&update_text="
        + update_data + "&internal=" + internal;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.open("POST", "index.php", true);


    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", params.length);
    xmlhttp.setRequestHeader("Connection", "close");

    //When button is clicked
    xmlhttp.onreadystatechange = function() {

        if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {


            showSubPanel('history', null, true);
            //Reload the case updates stream and history panels
\t\t    \$("#LBL_AOP_CASE_UPDATES").load("index.php?module=Cases&action=DetailView&record="+record + " #LBL_AOP_CASE_UPDATES", function(){


            //Collapse all except newest update
            \$('.caseUpdateImage').attr("src",showUpdateImage);
            \$('.caseUpdate').slideUp('fast');

            var id = \$('.caseUpdate').last().attr('id');
            if(id){
            toggleCaseUpdate(id.replace('caseUpdate',''));
            }


            loadingMessgPanl.hide();

            }

        );
\t}
}

        xmlhttp.send(params);



}
</script>
A;
    $updates = $focus->get_linked_beans('aop_case_updates', "AOP_Case_Updates");
    if (!$updates || is_null($focus->id)) {
        $html .= quick_edit_case_updates($focus);
        return $html;
        //return $mod_strings['LBL_NO_CASE_UPDATES'];
    }
    $html .= <<<EOD
<script>
\$(document).ready(function(){
    collapseAllUpdates();
    var id = \$('.caseUpdate').last().attr('id');
    if(id){
        toggleCaseUpdate(id.replace('caseUpdate',''));
    }
});
</script>
<a href='' onclick='collapseAllUpdates(); return false;'>{$mod_strings['LBL_CASE_UPDATES_COLLAPSE_ALL']}</a>
<a href='' onclick='expandAllUpdates(); return false;'>{$mod_strings['LBL_CASE_UPDATES_EXPAND_ALL']}</a>
<div>
EOD;
    usort($updates, function ($a, $b) {
        $aDate = $a->fetched_row['date_entered'];
        $bDate = $b->fetched_row['date_entered'];
        if ($aDate < $bDate) {
            return -1;
        } elseif ($aDate > $bDate) {
            return 1;
        }
        return 0;
    });
    foreach ($updates as $update) {
        $html .= display_single_update($update, $hideImage);
    }
    $html .= "</div>";
    $html .= quick_edit_case_updates($focus);
    return $html;
}
Пример #2
0
/**
 *
 * @package Advanced OpenPortal
 * @copyright SalesAgility Ltd http://www.salesagility.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 * along with this program; if not, see http://www.gnu.org/licenses
 * or write to the Free Software Foundation,Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301  USA
 *
 * @author Salesagility Ltd <*****@*****.**>
 */
function display_updates($focus, $field, $value, $view)
{
    global $mod_strings;
    $updates = $focus->get_linked_beans('aop_case_updates', "AOP_Case_Updates");
    if (!$updates) {
        $html = quick_edit_case_updates();
        return $html;
        //return $mod_strings['LBL_NO_CASE_UPDATES'];
    }
    $hideImage = SugarThemeRegistry::current()->getImageURL('basic_search.gif');
    $showImage = SugarThemeRegistry::current()->getImageURL('advanced_search.gif');
    $html = <<<EOD
<script>
var hideUpdateImage = '{$hideImage}';
var showUpdateImage = '{$showImage}';
function collapseAllUpdates(){
    \$('.caseUpdateImage').attr("src",showUpdateImage);
    \$('.caseUpdate').slideUp('fast');
}
function expandAllUpdates(){
    \$('.caseUpdateImage').attr("src",hideUpdateImage);
    \$('.caseUpdate').slideDown('fast');
}
function toggleCaseUpdate(updateId){
    var id = 'caseUpdate'+updateId;
    var updateElem = \$('#'+id);
    var imageElem = \$('#'+id+"Image");

    if(updateElem.is(":visible")){
        imageElem.attr("src",showUpdateImage);
    }else{
        imageElem.attr("src",hideUpdateImage);
    }
    updateElem.slideToggle('fast');
}
\$(document).ready(function(){
    collapseAllUpdates();
    var id = \$('.caseUpdate').last().attr('id');
    if(id){
        toggleCaseUpdate(id.replace('caseUpdate',''));
    }
});
</script>
<a href='' onclick='collapseAllUpdates(); return false;'>{$mod_strings['LBL_CASE_UPDATES_COLLAPSE_ALL']}</a>
<a href='' onclick='expandAllUpdates(); return false;'>{$mod_strings['LBL_CASE_UPDATES_EXPAND_ALL']}</a>
<div>
EOD;
    usort($updates, function ($a, $b) {
        $aDate = $a->fetched_row['date_entered'];
        $bDate = $b->fetched_row['date_entered'];
        if ($aDate < $bDate) {
            return -1;
        } elseif ($aDate > $bDate) {
            return 1;
        }
        return 0;
    });
    foreach ($updates as $update) {
        $html .= display_single_update($update, $hideImage);
    }
    $html .= "</div>";
    $html .= quick_edit_case_updates();
    return $html;
}